home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / a_utils / _archvrs / unix / pkzip19 / zip19 < prev    next >
Text File  |  1994-02-20  |  619KB  |  16,840 lines

  1. #! /bin/sh
  2. # This is a shell archive.  Remove anything before this line, then feed it
  3. # into a shell via "sh file" or similar.  To overwrite existing files,
  4. # type "sh file -c".
  5. # The tool that generated this appeared in the comp.sources.unix newsgroup;
  6. # send mail to comp-sources-unix@uunet.uu.net if you want that tool.
  7. # Contents:  atari history mac msdos nt os2 tailor.h vms
  8. # Wrapped by kent@sparky on Sun Aug 23 01:00:42 1992
  9. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  10. echo If this archive is complete, you will see the following message:
  11. echo '          "shar: End of archive 1 (of 11)."'
  12. if test ! -d 'atari' ; then
  13.     echo shar: Creating directory \"'atari'\"
  14.     mkdir 'atari'
  15. fi
  16. if test -f 'history' -a "${1}" != "-c" ; then 
  17.   echo shar: Will not clobber existing file \"'history'\"
  18. else
  19.   echo shar: Extracting \"'history'\" \(49244 characters\)
  20.   sed "s/^X//" >'history' <<'END_OF_FILE'
  21. XNote, this history contains mail addresses and ftp locations that no longer
  22. Xexist, such as addresses at wsmr-simtel20 and directory names containing
  23. Xw8sdz, among others.  For problems, the correct email address is
  24. Xzip-bugs@cs.ucla.edu.
  25. X
  26. X------------------------ Nov  7  1990   version 0.0 ------------------------
  27. X------------------------ Nov  8  1990   version 0.1 ------------------------
  28. X------------------------ Nov 12  1990   version 0.2 ------------------------
  29. X------------------------ Nov 14  1990   version 0.3 ------------------------
  30. XThank you for your comments.  Here is Zip 0.3 with almost all of that fixed.
  31. XThe changes include:
  32. X
  33. X1. Put \n\ for newlines in long strings (everyone had this problem).
  34. X2. Wrote my own bsearch (called search---different args).
  35. X3. Wrote my own timelocal (called invlocal), used whether STDC or not.
  36. X   (Note to Greg: look at the code---I found a simple way to do it.)
  37. X4. -m now deletes empty directories also.
  38. X5. Changed crc.c to util.c and put search() in util.c.
  39. X6. Changed "void *" to "voidp *" and made voidp void for STDC, else char.
  40. X7. Removed -a option.
  41. X8. Some minor changes to zip.doc.
  42. X
  43. XI did not do anything about Cliff Manis's problem with DIR not being
  44. Xdefined.  DIR should have been defined in sys/dir.h.  If it wasn't, then
  45. Xthere's something wrong with dir.h, or it is missing, or the opendir, etc.
  46. Xfunctions are missing.  I don't really want to think about what to do for
  47. Xthe latter possibility.
  48. X
  49. XNUnzip 3.99 does not appear to be Unix-ready.  It fails for file names longer
  50. Xthan 12 characters (Segmentation fault), cannot find explicit names that
  51. Xdo not contain a dot, and does not notice the Unix identifier (which should
  52. Xswitch off name to lower-case mapping).
  53. X
  54. X------------------------ Nov 20  1990   version 0.4 ------------------------
  55. XYo Zippers,
  56. X
  57. XHere is a first attempt at a Zip intended to work on System V.  Try using
  58. X"make sysv" for such systems.  I also included replacements for memset()
  59. Xand memcmp() by Bill Davidsen and James Dugal for systems without those.
  60. XUse "make old" to include those routines.  Sun's use getdents() like Sys V,
  61. Xeven though it's BSD, so use "make sun".  For others, try just "make".
  62. X
  63. XWhen using "make" a second time with a different request, it's best to erase
  64. Xall the .o files to force recompiling everything.
  65. X
  66. XWhat follows are the changes I made and some things to try if you get it
  67. Xcompiled.  Have fun.
  68. X
  69. XMark
  70. X
  71. X
  72. XChanges from Zip 0.3 to Zip 0.4:
  73. X
  74. X1.  Changed third arg of search() to size_t to make lint happier.
  75. X2.  Replaced zip.doc with a man page, zip.1 (raw) and zip.man (formatted).
  76. X3.  rename() replaced with link() and unlink().
  77. X4.  Fixed vem in central header and added REVISION and REVDATE #define's
  78. X    to zip.h.  (Didn't read Phil's appnote.txt carefully enough there.)
  79. X5.  Removed prototypes except for development host (NeXT).  (They're only
  80. X    there for my benefit anyway---they should not affect the resulting
  81. X    code.  Consider them some meager documentation.)
  82. X6.  Changed rindex() to strrchr().
  83. X7.  Improved behavior on a write failure when -b is used.
  84. X8.  Added Bill Davidsen's and James Dugal's memset(), memcpy(), and
  85. X    memcmp() routines under the trusty ZMEM #define.
  86. X9.  Check that zip file is writeable before doing any real work.
  87. X10. Added #ifdef REGEX to use regcmp(), regex() instead of re_comp(),
  88. X    re_exec().  (We'll see if this works.)
  89. X11. Replaced opendir(), readdir(), closedir() with my own opend(), readd(),
  90. X    and closed() routines that use getdirentries() on BSD and getdents() on
  91. X    System V (I hope) and Sun's.  An #ifdef DIRENT selects getdents().
  92. X12. zip.h no longer #includes string.h, instead defining the string
  93. X    functions used explicitly.
  94. X
  95. X
  96. XIf you get Zip 0.4 to compile, here are some things to test:
  97. X
  98. X1.  Try zipping up some stuff, of course.  Use all the options that are
  99. X    implemented.  Especially try -rp and -rpm on a directory tree (use
  100. X    *test* files and directories, of course).
  101. X2.  Naturally check with unzip -t, but also check with "zip xxx" where
  102. X    xxx.zip is the zip file.  This should say "nothing to do", but if it
  103. X    says "error in zip file structure", there's a problem.
  104. X3.  After zipping, check that there are no $Z* files leftover.
  105. X4.  Try using -b, specifying a path on another device.  Check for $Z*'s.
  106. X5.  Try -d and a regular expression (like \*.o) on a zip file.
  107. X6.  And I'm interested in timing---try it on a 500K or so text file.
  108. X
  109. X------------------------ Nov 27  1990   version 0.5 ------------------------
  110. XHail fellow zippers,
  111. X
  112. XHere's Zip 0.5.  The biggie is it now includes implosion, courtesy of Rich
  113. XWales.  Even as we speak, he is working on new algorithms for implode that
  114. Xpromise to be significantly faster.  He might even get a paper out of it ...
  115. X
  116. XYou can use the -s option (shrink only) when testing to save a little time,
  117. Xbut also try it normally to test implosion (if you test with text files
  118. Xof reasonable length, implosion will be chosen for most of them).  Also, for
  119. Xspeed testing of implosion, use -i to not waste time trying to shrink.
  120. X
  121. XIncluding implosion about doubles the size of zipnn.tar.Z, so I would like
  122. Xsome input on distributing subsequent versions.  Would y'all like to keep
  123. Xon getting the uuencoded version via mail, or would you prefer a notice
  124. Xabout availability via anonymous ftp on simtel20.army.mil in <w8sdz.zip>?
  125. X(I have been sending the previous versions to Keith to put there, and will
  126. Xcontinue to do so.  I do not know what the lag time is for him to move it
  127. Xthere.)
  128. X
  129. XThe other important change is that this is another attempt at getting the
  130. Xdirectory access routines working on all systems.  Read the installation
  131. Xpart of the manual page (zip.man).  And if you feel like, read the whole
  132. Xthing.  I'm also taking suggestions for and bugs in the documentation.
  133. X
  134. XThe differences from Zip 0.4 include:
  135. X
  136. X1. Changed all occurences of "size_t" to "extent" and typedef'ed extent
  137. X   to size_t (after an #include <stddef.h>) for ANSI C, or unsigned int
  138. X   otherwise.  If anyone finds that they have a non ANSI C, that size_t
  139. X   is defined, and that it is not the size of the compiler's int, then
  140. X   please let me know.
  141. X2. Changed help() to put the help text in a static array of strings and
  142. X   then printf() for each line.  Some compilers barfed on the long
  143. X   string.  Suggested by davidsen@crdos1.crd.ge.com.
  144. X3. Added Rich Wales' implode routines, made their inclusion the default
  145. X   (changed #ifdef IMPLODE to #ifndef NOIMPLODE).
  146. X4. Put "extern int errno;" in unixfile.c (redundant extern's should be ok).
  147. X5. Minor changes to the man page (zip.1 and zip.man).
  148. X6. Added warnings for names given on the command line that are not matched.
  149. X   Lack pointed out by grimesg@sj.ATE.SLB.COM (George).
  150. X7. Changed back to opendir(), etc. on BSD systems.
  151. X8. Added NDIR #define for HPUX to #include <ndir.h> instead of <sys/dir.h>.
  152. X9. Redid Makefile, adding next (use shared library), sysvpw (System V's
  153. X   that require linking the libPW library for regex routines), and hpux
  154. X   (see #8 above).
  155. X
  156. XAs usual, report problems to info-zip@wsmr-simtel20.army.mil.  If you wish,
  157. Xyou can, in addition, send the same report to me (madler@piglet.caltech.edu)
  158. Xor Rich (wales@cs.ucla.edu) if the problem is with implosion (i* files) for
  159. Xquicker reponse.
  160. X
  161. Xyour humble servant,
  162. XMark Adler
  163. X------------------------ Dec  7  1990   version 0.6 ------------------------
  164. XGreetings and Felicitations Honorable Zip Compatriots,
  165. X
  166. XI have uploaded Zip 0.6, which incorporates most of your helpful comments,
  167. Xto Simtel20.Army.Mil, and it should evenually end up in <W8SDZ.ZIP> as
  168. XZIP06.TAR-Z.  The most significant change is the addition of encryption
  169. Xboth as the -e option in Zip, and a new program, ZipCloak, that encrypts
  170. Xand decrypts zip entries.  This surely adds some new portability problems,
  171. Xdue to the getp() routine which reads a password from the terminal with no
  172. Xechoing.  We'll see how well this flies ...
  173. X
  174. XIf someone wants to PKZIP up the tar.Z file, please do so.  I didn't zip
  175. Xit up myself because a) I'm lazy, and b) PKZIP can compress it better
  176. Xanyhow, and I don't have a PC.
  177. X
  178. XAlso, there is an EXPORT symbol used to remove encryption, so I can make
  179. Xan export version that does not have -e or ZipCloak.  This version will
  180. Xsimply be missing a few source files and have a different Makefile.
  181. X
  182. XI also added a few systems to the Makefile, and made some other changes to
  183. Xit based on all your detailed comments.  If it still works after all that,
  184. XI'll be amazed.
  185. X
  186. XThose and other changes from 0.5 to 0.6 are detailed at the end of this note.
  187. X
  188. XI have not addressed the portability problem with the implode routines,
  189. Xsince that is Rich's domain.  I have no idea what is causing it.  (For those
  190. Xwho don't know, one system produced remarkable 90% compression rates with
  191. Ximplode, but alas, it is a bug.)
  192. X
  193. XOne fellow complained that zipping up the README file results in a zip file
  194. Xthat is larger than the original, even though Zip claims it compressed it.
  195. XWell, it did compress it, but the ZIP file format has an overhead of
  196. X76+2*N bytes per file+22 bytes, where N is the length of the file name.
  197. XAnd that's without comments or "extra" information.  So, a zip file with a
  198. Xsingle file whose name has six characters has an overhead of 110 bytes.
  199. XREADME gets shrunk by 16% from 274 bytes to 230 bytes, resulting in a total
  200. Xzip file size of 340 bytes---larger than the original file (274 bytes).
  201. XThe moral is don't expect zip to compress a single small file.  The other
  202. Xmoral is use unzip -v to see the compression.
  203. X
  204. XSomeone else asked about multi-disk zip files.  I'm not sure I believe in
  205. Xthose, since PKZIP and PKUNZIP do not appear to suppport them (though it is
  206. Xpart of the ZIP file definition in APPNOTE.TXT).  What I was planning on
  207. Xdoing for that case was to write a ZipSplit program that would take a large
  208. Xzip file and try to optimally split it into the fewest number of zip files
  209. Xthat are all less than the specified size.  Each would be a complete, stand
  210. Xalone zip file---not part of a single, multi-disk zip file.  There would
  211. Xalso be a ZipMerge program.
  212. X
  213. XThis is the version of Zip that will live in infamy (note the revision date).
  214. XOf course, some current Presidents of the United States think that should be
  215. XSeptember 7th, but I won't name any names.
  216. X
  217. XI am going on vacation for about two weeks, so I expect to find many new
  218. Xproblems reported upon my return.
  219. X
  220. XAnd lastly, for my Holiday Greetings: Party On Dudes.
  221. X
  222. XMark Adler
  223. Xmadler@piglet.caltech.edu
  224. X
  225. X
  226. XHere are the changes from Zip 0.5 to Zip 0.6:
  227. X
  228. X1.  Minor documentation changes (zip.1 and zip.man).
  229. X2.  Fixed an embarrasing lack of recursion in opend/readd/closed functions
  230. X    that only existed in 0.5.
  231. X3.  Moved $(LDFLAGS) to end of the linking command line in Makefile.
  232. X4.  Added make dnix for DNIX 5.2, 5.3 not using optimization (no -O).
  233. X5.  Wrote ZipCloak for encryption and decryption.
  234. X6.  Rich changed the output routines of implode to use zfwrite and zputc to
  235. X    provide hooks for encryption (defined in crypt.h).  Also removed
  236. X    function prototypes unless PROTO defined.
  237. X7.  Added encryption (-e) to Zip.
  238. X8.  Added make pyramid (use rindex() instead of strrchr()).
  239. X9.  Changed make to $(MAKE) and cc to $(CC) in Makefile.
  240. X10. Took out strip in Makefile.
  241. X11. Changed year from 1991 to 1990.  (How'd *that* get in there?  Of course,
  242. X    it's not as bad as when I wrote a check the other day and dated it 1977.
  243. X    I think my brain cell isn't working as well as it used to.)
  244. X12. Added make cray (use scc instead of cc).
  245. X13. Added make amdahl (use system() instead of rmdir()).
  246. X14. Added entry of one-line comments for added files (-c).
  247. X15. Put comment delimiters around name following #endif's in Rich's code.
  248. X
  249. X------------------------ Feb 13  1991   version 0.7 ------------------------
  250. XFellow stuck zippers,
  251. X
  252. XWell folks, it's been a while since 0.6. so there have been a lot of
  253. Xchanges on the way to 0.7.  The exhaustive listing is below, but here are
  254. Xsome highlights ...
  255. X
  256. XImplode now (appears) to be PKUNZIP compatible.  There were many odd
  257. Xlittle requirements implosed by the coding of PKUNZIP that were obtained
  258. Xfrom Phil Katz and associates.  Now that Rich has that working, he will
  259. Xlikely be working on much faster string matching routines to speed up
  260. Ximplode.
  261. X
  262. XUser interrupts (control-C or kill) are now caught and the temporary files
  263. Xare deleted, making for a clean getaway.
  264. X
  265. XSelf-extracting zip files for MSDOS can now be processed, with the
  266. Xextensions zip, ZIP, exe, or EXE.  This allows you to make self-extracting
  267. Xzip files for MSDOS by taking an existing one (like PKZ110.EXE) and
  268. Xdeleting all the entries to get a prototype self-extracting zip file that
  269. Xcan be copied and added to.  Of course, you should only do this if you are
  270. Xa registered user of PKZIP.  Note that if the file does not end in .zip,
  271. Xyou have to give the full name.
  272. X
  273. XI have relaxed some of the restrictions on zip files to allow processing
  274. Xones with "authenticity verification" (applied by the PUTAV program that
  275. Xcomes with PKZIP).  Of course, the authenticity no longer checks out if
  276. Xyou muck with the file, but at least you can muck with it now.
  277. X
  278. XThe Makefile has been considerably simplified, thanks to suggestions from
  279. XJean-Loup Gailly.  Also, I wrote my own sh expression matcher, eliminating
  280. Xthe regular expression hassles, and the REGEX symbol and -lPW options in
  281. Xthe Makefile.
  282. X
  283. XMany, many cosmetic changes, the most dangerous of which was turning on
  284. Xprototypes again in the hopes we can get them to work.  If they cause you
  285. Xproblems, record the problems (for me), and then add a -DNOPROTO to the
  286. Xappropriate line in the Makefile and try again.
  287. X
  288. XThis version now compiles under Microsoft C 5.1 and Turbo C++ 1.0, with
  289. Xmuch thanks to Jean-Loup Gailly.  I say "compiles" and not "works" because
  290. XI have not thoroughly tested it.  It does work, but there may be errors in
  291. Xthe port as well as errors in the design.  By the latter I mean that there
  292. Xmay be some disagreement over what you expect it to do and what it does,
  293. Xespecially with regards to upper and lower case names and wildcard
  294. Xpatterns.  Also, the implode routines do not yet work under MSDOS, so the
  295. Xcompilations are done using NOIMPLODE.  There are two dumb batch files to
  296. Xdo the compile: doturboc.bat and domsc.bat.  If someone would like to
  297. Xwrite make files for the make utilities that come with those languages,
  298. Xplease be my guest.  I'm just too lazy.  However, I would probably resist
  299. Xincluding make files that require a make utility that does not come with
  300. Xthose languages, be it commercial, shareware, or free.
  301. X
  302. XThere are two new programs: ZipSplit and Ship.  ZipSplit tries to split a
  303. Xbig zip file into the smallest number of zip files less than a specified
  304. Xsize.  This is to aid in using zip to backup to floppies.  It has the
  305. Xlimitation that it cannot break up an entry in a zip file, since it makes
  306. Xcomplete, standalone zip files.  This means if any entry is larger than
  307. Xthe specified size (plus some overhead), zipsplit will give up and not do
  308. Xthe split.  It does *not* implement the multi-disk zip file format implied
  309. Xin APPNOTE.TXT.  ZipSplit will optionally write an index file and deduct
  310. Xthe size of that file from the first zip file so both will fit on the
  311. Xfirst disk.
  312. X
  313. XShip is a fixed-up version of a program I have been using myself for some
  314. Xtime in place of uuencode/uudecode.  It's purpose is to facilitate sending
  315. Xzip files through the mail.  It uses a more efficient coding scheme than
  316. Xuuencode (four bytes per five characters instead of three bytes per four
  317. Xcharacters) and includes a crc at the end of each file to check the
  318. Xveracity what was received.  It can split its output to a specified size
  319. Xand recombine it automatically at the other end, verifying the sequence.
  320. XIt can also mail the parts to a specified address, with subject lines
  321. Xidentifying the parts, instead of making a bunch of files that you're just
  322. Xgoing to mail and delete anyway.  Example:
  323. X
  324. X     % ship -500 -m saddam@pickle.iq README zip07.zip
  325. X     README shipped
  326. X     zip07.zip shipped
  327. X     files part0001..part0004 mailed
  328. X
  329. Xwill mail README and zip07.zip together in four chunks of 500 or fewer
  330. Xlines each.  At the other end, Saddam can save the parts into the files
  331. Xnamed in the subject lines (part0001..part0004), and then do:
  332. X
  333. X     % ship -u part*
  334. X     README received
  335. X     zip07.zip received
  336. X
  337. XFor now, zip.1 (and zip.doc) are incomplete as far as MSDOS goes.  I'll
  338. Xput off doing that until the MSDOS version has stabilized.  Likewise, I
  339. Xhave put off writing zipcloak.1, zipsplit.1, and ship.1 for the same
  340. Xreason.
  341. X
  342. XThere are, of course, all the little changes that fix bugs (what are
  343. Xthose?), make the Makefile work on more systems, documentation, and,
  344. Xfor the alert reader, an undocumented option ...
  345. X
  346. XAs usual, send reports to info-zip@wsmr-simtel20.army.mil, so everyone
  347. Xcan get a chuckle out of whatever new bugs I've introduced.
  348. X
  349. XMark Adler
  350. Xmadler@pooh.caltech.edu
  351. X
  352. X
  353. XChanges from release 0.6 to release 0.7:
  354. X
  355. X1.  Changed Makefile to use mv instead of -o on compiles.
  356. X2.  Added MAKE = make to Makefile.
  357. X3.  Catch user interrupt or termination and delete temporary files.
  358. X4.  Allow general purpose flags in local and central headers to differ in
  359. X    the "reserved" bits.  Keep both for copying zip entries verbatim.
  360. X5.  Removed prototype for closedir--return value not used and inconsistent
  361. X    across systems.
  362. X6.  Wrote ZipSplit to break a large zip file into the smallest number of
  363. X    zip files less than a specified size.  Run zipsplit with no arguments
  364. X    to see the command help.
  365. X7.  Put error messages in globals.c to be common across zip, zipcloak, and
  366. X    zipsplit.  Use #define's in zip.h for error numbers.
  367. X8.  Changed getp() to open a new file for the terminal device, and added
  368. X    the echon() function to turn echoing back on when interrupted at
  369. X    password prompt.
  370. X9.  Added warn()'s to distinguish various zip file structure errors.
  371. X10. Allow "extra" fields in local and central headers to differ.
  372. X11. Fixed percent compression calculation to work for very large files.
  373. X12. Included the program (makecrc.c) that generates the CRC table.
  374. X    makecrc.c is not compiled or run by the Makefile, but is present for
  375. X    completeness.
  376. X13. Added an undocumented (except for here) option, -v, to zip that checks
  377. X    for "oddities" in the zip file structure and points them out if found
  378. X    (but continues processing).
  379. X14. Put prototypes in crypt.h inside #ifdef NeXT to avoid redefinition
  380. X    problems with other compilers.
  381. X15. Added "make zilog" for Zilog S8000 running Zeus 3.21.
  382. X16. Minor changes to the manual page (zip.1 and zip.doc).
  383. X17. Fixed bug in replace() (manifested by -b option).
  384. X18. readzipfile() now also checks the central directory start and size in
  385. X    the end of central directory header.
  386. X19. Allow modification of self-extracting zip files (exe instead of zip).
  387. X20. Allow .ZIP as valid suffix as well as .zip (also .EXE and .exe).
  388. X21. Cleaned up malloc usage, free'd everything malloc'ed.
  389. X22. fclose'd all fopen'ed files explicitly.
  390. X23. Corrected assignment of one ftell() result from an int to a long.
  391. X24. Considerably simplified Makefile, based on Jean-Loup Gailly's
  392. X    suggestions.
  393. X25. Renamed unixfile.c to fileio.c in anticipation of non-unix support.
  394. X26. Removed const's (pesky little buggers caused too many problems).
  395. X27. Wrote my own shell expression compare routine, took REGEX and -lPW's
  396. X    out of Makefile, which removed the sysvpw make option.
  397. X28. Added tempname() prototype to crypt.h for the implode routines to use.
  398. X29. Trying string.h for prototypes of string functions if __STDC__
  399. X    defined, which is what unzip.h does.
  400. X30. Turned prototypes on if __STDC__ defined (we'll try this one more
  401. X    time).  They can be turned off using NOPROTO.
  402. X31. Improved source documentation.
  403. X32. Changed prototype of open in fileio.c to OF((char *, int, ...)).
  404. X33. Removed "local" from prototypes of main() (after all, it's *not*
  405. X    local).
  406. X34. Wrote Ship program to supplant uuencode--slightly more efficient, has
  407. X    error checking, file splitting, automatic mailing, other features.
  408. X    Ship currently uses the command:
  409. X        /usr/ucb/mail -s subject < tempfile
  410. X    to send mail.  Please let me know what works for your system.  Note
  411. X    that I want to be able to specify a subject line.
  412. X35. Ported to MSDOS Microsoft C 5.1, based on Jean-Loup Gailly's work.
  413. X36. Fixed add/update bug when -p not used.
  414. X37. Handle lower case conversion and devices (e.g. C:) for MSDOS.
  415. X38. Indented the #ifdef/#ifndef constructs that do not contain function
  416. X    definitions, to improve the readability somewhat.
  417. X39. Cleaned up error handling.  Now use perror() for i/o errors.  Put the
  418. X    errors and messages in ziperr.h.
  419. X40. Ported to MSDOS Turbo C++ 1.0.
  420. X41. Implemented wild card expansion on the command line for MSDOS and
  421. X    handle MSDOS matching (*.* == all, not *).
  422. X42. Changed version required to unzip to 11 (1.10) since the implode
  423. X    routines can procude an overlapping match one away from the end of the
  424. X    window (PKUNZIP 1.00 requires two away from the end).
  425. X43. Changed old next make option to next10 (for version 1.0) and added a
  426. X    new next make option for 2.0 (just called next) that uses the -object
  427. X    linking option for smaller executables.
  428. X44. Added -z option to take a multi-line zip file comment from stdin.
  429. X45. Changed temporary names from $ZXXXXXX to _ZXXXXXX, where XXXXXX is
  430. X    filled in by mktemp().  This avoids problems with "rm $Z*" in sh.
  431. X46. Got new implode routines from Rich that are (hopefully) PKUNZIP
  432. X    compatible.
  433. X47. When -b is not specified, put the temporary files in the same
  434. X    directory (i.e. the same device) that the zip file is (or will be) in.
  435. X48. Added doturboc.bat and domsc.bat files to compile for Turbo C++ 1.0
  436. X    and Microsoft C 5.1.  I am interested in successes and failures with
  437. X    other versions of those compilers.  In this version, the implode
  438. X    routines do not work under MSDOS.
  439. X------------------------ May  6  1991   version 0.8 ------------------------
  440. XBuenos Dias Amigos,
  441. X
  442. XHeer ees dee Cinco de Mayo reeleese of seep, aka Zip 0.8.  The changes
  443. Xfrom 0.7 are in the (long) list below, but here are some highlights:
  444. Xfaster implode, faster shrink, first attempt at a VMS version (thanks
  445. Xto Cave Newt), and a new program, ZipNote, to aid in editing zip file
  446. Xcomments.  To compile under VMS, do an "@makevms.com".  To compile using
  447. XMircosoft C do a "make makefile.msc".  To compile using Borland (Turbo)
  448. XC, do a "make -fmakefile.bor".  Please try to break any or all of these
  449. Xprograms in every conceivable way--we're getting close a public release.
  450. XThank yew fer your support.
  451. X
  452. XMark Adler
  453. Xmadler@pooh.caltech.edu
  454. X
  455. XChanges from 0.7 to 0.8:
  456. X
  457. X1.  Added the -n option to prevent compressing already compressed files.
  458. X    Documented -n in zip.1.
  459. X2.  Check the length of the compressed data in zipup() in case implode or
  460. X    shrink has a bug.
  461. X3.  Fixed -v option to not complain about needing PKUNZIP 1.1.
  462. X4.  Added report of store/shrink/implode sizes when -v (verbose) used.
  463. X5.  Put in Rich's patch to fix 100% implosion bug.
  464. X6.  Fixed -i bug.
  465. X7.  Made changes to im_ctree.c and implode.c to (hopefully) make it work
  466. X    under MSDOS.  (Jean-Loup said declare topmaxvals and botmaxvals as
  467. X    U_INT in im_ctree.c, and use MSDOS, not __MSDOS__ in implode.c.)
  468. X8   Added implode routine compilation to domsc.bat and doturboc.bat.
  469. X9.  Replaced FILENAME_MAX with FNMAX, which is now always 1024.  (It seems
  470. X    FILENAME_MAX is incorrectly set to 14 on some System V Unixii.)
  471. X10. Changed BEST to -1 so it is different from STORE (=0).  Redid some of
  472. X    the method logic in zipup().
  473. X11. Changed wb+ to w+b in implode.c.
  474. X12. Removed "nothing to do" error for -u and -f.
  475. X13. Zip source distributions will now have tabs removed, except for
  476. X    Makefile and Makefile.exp (no feelthy tabs rule).
  477. X14. Changed zip error on open failure to a warning.  This accounts for
  478. X    files that do not have read permission or are locked, and files
  479. X    deleted during the zip.  For entries being updated, the old entry is
  480. X    copied over instead.  This change had the side effect of removing the
  481. X    zipskip() routine.
  482. X15. Removed OBJC dependencies in Makefile.exp (didn't belong).
  483. X16. Removed strip from Makefile, instead using the -s link option.
  484. X17. Fixed -um and -fm to delete files whose entry's times were checked in
  485. X    the archive.
  486. X18. Put portability stuff common to zip.h and crypt.h into tailor.h.
  487. X19. Added mark tracing to -v (for debugging).
  488. X20. Changed name and zname logic--an external name is always converted
  489. X    into an internal zname, and vice-versa.  zname is now always
  490. X    malloc'ed.
  491. X21. Fixed -z to use CRLF between lines (for PKZIP) and have no newline
  492. X    after the last (or only) line.
  493. X22. Added clean to Makefile (deletes *.o, zip, zipcloak, zipsplit, ship).
  494. X23. Replaced LDFLAGS with LFLAGS1 and LFLAGS2 in Makefile (splits link
  495. X    options before and after object files as in unzip).
  496. X24. Added scodos to Makefile (from Bill Davidsen).
  497. X25. Included stdio.h in tailor.h--removed stdio.h from zip.h and
  498. X    implode.h.
  499. X26. Do not include stddef.h if M_XENIX defined.
  500. X27. Cast the arguments of all free() calls to (voidp *).
  501. X28. Added casts to char * for memset() and qsort() args in zipsplit.c.
  502. X29. Changed implode.h to define malloc and str* properly.
  503. X30. Fixed invlocal() to handle integer overflow correctly, as well as
  504. X    reliably across compilers.
  505. X31. Got new implode.h from Rich with fix #29 above.  Removed stdio.h
  506. X    include.
  507. X32. Commented out the abort() calls in im_ctree.c.
  508. X33. -ee requests a verification of the encryption password.
  509. X34. malloc and free tempath.
  510. X35. Documented -, SCO, and scodos in zip.1, and - in help().
  511. X36. Added revision.h for Zip revision number and date.
  512. X37. -u and -f with no arguments now (both) freshen the entire archive.
  513. X38. Use /Oait instead of /Ox for MSC to avoid loop optimization (buggy on
  514. X    5.1, and sometimes even crashes compiler!).
  515. X39. Added ! (reverse) range matching to shmatch(), and early abort on '*'
  516. X    failures (speeds up pathological patterns).  Cleaned up '\' (escape)
  517. X    handling.
  518. X40. Changed '!' in ship to '{' (some EBCDIC translations do not include
  519. X    !).  However, unship (ship -u) still understands '!'.  Also added the
  520. X    -v option of ship to print out the version and revision date.  Also
  521. X    now refuse to overwrite an existing file when unshipping (ship -u),
  522. X    but there is a -o option to overwrite anyway.
  523. X41. Added a "fast" mode to ship using hard-arithmetic coding that is
  524. X    nearly as efficient as base 85 coding, but much faster on 16-bit
  525. X    machines (base 85 coding uses 32 bit multiplication and division).
  526. X42. Put tailor.h back in ship.c, so that ship.c can stand on its own.
  527. X43. Made -p the default, and added a new option, -j to do the opposite
  528. X    (junk directory names).  -p is still there but does nothing, so as to
  529. X    avoid annoying PKZIP users.  Changed documentation and help()
  530. X    accordingly.
  531. X44. If -j is used, and two files are to be added with the same name, then
  532. X    zip exits with an error.
  533. X45. Wrote ZipNote for editing zipfile comments.  Just do zipnote for
  534. X    usage.
  535. X46. Replaced Rich's im_lmat.c with a new one from Jean-Loup.  Improves the
  536. X    speed of implode by a factor of two, and even more for very large
  537. X    files.
  538. X47. Reduced the execution time of shrink by 33% simply by moving the code
  539. X    around (eliminated some unnecessary calls, moved some tests).
  540. X    Shrink's execution time is now about 50% more than compress (it used
  541. X    to take over twice as long).  Hash tables for shrink are still
  542. X    intended for a future release.
  543. X48. VMS mods from Greg: replace() unlinks only after copy, changed
  544. X    delete() to destroy(), added code for deletedir(), use creation time
  545. X    instead of modification time, warn if stamp() attempted, changed
  546. X    includes, make link rename and unlink delete, added findfirst,
  547. X    findnext stuff, added wild() for VMS, modified newname(), procname().
  548. X49. Implemented internal<-->external name conversions for MSDOS and VMS.
  549. X50. For VMS matching, changed ? to %, removed bracketed ranges.
  550. X51. Added makevms.com, stolen from Unzip (vms_make.com).
  551. X52. Implemented -k (force the zip file to look like it was made by PKZIP).
  552. X53. Removed implode for VMS (it crashes--haven't tracked down where).
  553. X54. Got Jean-Loup's makefile.dos working for MSC 5.1 (makefile.msc) and
  554. X    Turbo C++ 1.0 (makefile.bor).
  555. X------------------------ Jul 11  1991   version 0.9 ------------------------
  556. XHey gang,
  557. X
  558. XHere is our very-nearly-ready-to-release version of Zip.  There will be no
  559. Xfeatures added or changed from 0.9 to 1.0--only bugs fixed.  I hope that
  560. Xwe can get 1.0 out pretty quickly then.  This is really your last chance to
  561. Xfind bugs before it goes out, so please, please test all the programs as
  562. Xmuch as you can.  Try all the features, if possible, and perhaps try to
  563. Xthink of ways to break the programs.  Also, and this is very important, read
  564. Xthe documentation in zip.doc and "debug" that too.  I already know that it
  565. Xis not complete in 0.9, but please send any comments about errors, omissions,
  566. Xformat, or whatever to Info-ZIP, even if they seem obvious.
  567. X
  568. XThe highlights of the changes from 0.8 to 0.9 are: faster, slicker implode;
  569. Xoperation in small model on MSDOS for speed; a new temporary file interface
  570. Xfor faster operation on small files; some shrink improvements; and some new
  571. Xoptions (-y, -g, -q).  Also, ship has been enhanced in several ways, not the
  572. Xleast of which is a help option (-h).
  573. X
  574. XHave fun.
  575. X
  576. XMark Adler
  577. Xmadler@tybalt.caltech.edu
  578. X
  579. X
  580. XChanges from 0.8 to 0.9:
  581. X
  582. X1.  Removed the "not implemented yet" note in help() for -k (it *is*
  583. X    implemented now).  Removed from bug list in zip.1 too.
  584. X2.  Fixed Turbo C implode bug.
  585. X3.  Added /link /e in makefile.msc for ship.c.
  586. X4.  Made handler() in zipnote.c the same as handler() in zipsplit.c.
  587. X5.  Added -y option in Unix to store symbolic links as such.  (We need
  588. X    Unzip to be aware of symbolic links and use symlink() to recreate them.)
  589. X6.  Ignore control characters in unship input.
  590. X7.  Use prototypes and ANSI libraries if MSDOS.  (Used to check for Turbo C,
  591. X    but Microsoft C 6.0 also does not define __STDC__ unless strict ANSI
  592. X    is requested.)
  593. X8.  Added mod to ct_fsort() from Rich that should remove any qsort()
  594. X    dependencies in implode output.
  595. X9.  Removed some 32/16-bit prejudices in util.c and crypt.c that affect
  596. X    64-bit integer (short, int, and long) machines (Cray).
  597. X10. Added System V MAILX option to ship.c to use the mailx command.  This
  598. X    is automatically activated by DIRENT if ship is compiled by the zip
  599. X    makefile.
  600. X11. Added patches from Greg Roelofs for echo control on Cray and Amdahl.
  601. X    The patch uses termio.h and ioctl(), and is assumed for all System V,
  602. X    not just those (we'll see how this flies).
  603. X12. Changed -Ox to -Oacegit -FPi87 in makefile.msc.  Added /nologo to link.
  604. X13. Applied J-L's 082 mods (Sinatra style): select 4K window for < 5.5K,
  605. X    8K window for >= 5.5K files (just like PK does); various im_ctree.c
  606. X    mods verbatim (except for the treename warning, which I did differently);
  607. X    various im_lmat.c mods verbatim (except macros are done the ugly portable
  608. X    way); farmalloc'ed in shrink.c; changed makefile.msc and makefile.bor to
  609. X    use small model; added J-L to zip.1 acknowledgements (oops).
  610. X14. Moved struct zlist's and struct flist's to far storage (needed by above
  611. X    mods).  Unfortunately, I can't move the names and other things pointed to
  612. X    by those structures into the far space, since they are arguments to
  613. X    library functions like strcmp() and fwrite().
  614. X15. Changed zipup() to both shrink and implode only on files smaller than
  615. X    BSZ.  Also in that case, free up shrink data structures before allocating
  616. X    the implode data structures.  Changed from fopen() to open() except for
  617. X    VMS.
  618. X16. Fixed bug in dosmatch() to free malloc'ed space.
  619. X17. MINIX mods (do not need minix make option): call tempname() with a unique
  620. X    character (MINIX mktemp() flawed); defined S_IWRITE as S_IWUSR if S_IWUSR
  621. X    defined; removed explicit signal dereference.
  622. X18. Fixed bug in unship when used as a filter with no args.
  623. X19. Changed getnam() to not use static storage.
  624. X20. Copy permissions from old to new zip file (zip, zipcloak, zipnote).
  625. X21. Added patches for AT&T 3B1, added 3b1 target to makefile, added to zip.1.
  626. X22. Made FNMAX 256 for MSDOS (is 1024 otherwise).
  627. X23. Used the "pyr" predefined symbol for Pyramid systems in tailor.h.
  628. X24. Added Greg's VMS mods to ship.c.  Added help to ship.c (-h or -?).
  629. X    Changed meaning of -nnn arg from lines to K.
  630. X25. Moved ZMEM routines to fileio.c to properly include them in zipnote and
  631. X    zipsplit.
  632. X26. Added -s option to ship to specify a subject line prefix.
  633. X27. Fixed -z in zip to not trash leading blank lines in the comment.
  634. X28. Made ship recognize "unship" in argv[0] a little more flexibly.
  635. X29. Made sure temporary zip files are closed before being deleted by an
  636. X    error or interrupt.
  637. X30. Added a new temporary file interface and new source files tempf.c and
  638. X    tempf.h.  This avoids making temporary files for small (<16k) output.
  639. X    Both shrink and implode use this.
  640. X31. Added OS/2 patches, files.  However, left zip case-sensitive for OS/2
  641. X    names, as in Unix.
  642. X32. Removed amdahl target in makefile, using UTS symbol instead.
  643. X33. Changed -y to depend on definition of S_IFLNK.
  644. X34. Avoid leading periods on lines in ship output by inserting a space.
  645. X35. Ship is now extensible: added a warning for "unsupported keyword".
  646. X    Such keywords can appear before the "ship" line, for example.
  647. X36. Added -g option to allow "growing" the zip file.  If just adding new
  648. X    entries to a zip file, -g will write over the old zip file without
  649. X    creating a temporary.  The danger is that if there is an error, the
  650. X    old zip file will be lost.  If not just adding, then -g is ignored.
  651. X37. Added aux (A/UX) target to makefile.
  652. X38. In shrink.c, removed unnecessary FreeList and ClearList arrays, and
  653. X    the recursive Prune() routine.  This also resulted in a speedup in
  654. X    shrink of about 15%.  It is now only about 30% slower than Unix compress.
  655. X39. Added -q option for quiet operation.
  656. X------------------------ Sep 21  1991   version 1.0 ------------------------
  657. XHello world!
  658. X
  659. XThis is the first public release version of Zip and its cohort utilities.
  660. XWe hope you enjoy using it much much more than we enjoyed writing it and
  661. Xtrying to get it to work on every fritzing raffing bliffing nobbin Unix
  662. Xsystem in the galaxy.
  663. X
  664. XPlease feel free to send any problems, complaints, suggestions, kudos,
  665. Xridicule, or whatever to zip-bugs@cs.ucla.edu.  If there were a way to
  666. Xsend cookies over the net, we'd accept those too.
  667. X
  668. XThank yew fer yur support.
  669. X
  670. XMark Adler
  671. Xmadler@tybalt.caltech.edu
  672. X
  673. X
  674. XChanges from 0.9 to 1.0:
  675. X
  676. X1.  Removed some pesky carriage returns masquerading as spaces in fileio.c
  677. X    and zipup.c.
  678. X2.  Removed #include memory.h in tempf.c (string.h good enough).
  679. X3.  Compile ship in doturboc.bat.
  680. X4.  Miscellaneous zip.1 (zip.doc) changes.
  681. X5.  Fixed mistake in stamp() in fileio.c (didn't double seconds).
  682. X6.  Applied Jean-Loup's mods for Cray's (do not assume 16-bit shorts).
  683. X7.  Removed pyramid make option, since #ifdef pyr seems to work.
  684. X8.  Added some casts to tempf.c to clean up some warnings.
  685. X9.  Added comment to makefile.exp saying what it is.
  686. X10. Removed length checks in zipup.c to fix problem with using Vax variable
  687. X    record length formats.
  688. X11. Fixed VMS replace-across-devices problem.
  689. X12. Changed order of include's in implode.h to make tailor.h show up first.
  690. X13. Added Convex mods and make target.
  691. X14. Fixed path delimiter under VMS for unship.
  692. X15. Added ship to makevms.com.
  693. X16. Put in new copyright messages.
  694. X17. Added aix make target.
  695. X18. Fixed zipsplit.idx to start counting at one like the file names.
  696. X19. Changed -a (append VMS version number) to -w to leave -a open for a
  697. X    possible future option.
  698. X20. Back to separate makefiles for Microsoft and Borland (.msc and .bor).
  699. X21. Workaround in fileio.c for Borland stat() bug: stat() succeeds for wild
  700. X    card names that match existing files.
  701. X22. Added "(did you remember to use binary mode when you transferred it?)"
  702. X    to the "probably not a zip file" warning.
  703. X23. Changed utilities to append .zip only when the zip file name does not
  704. X    contain a dot.
  705. X24. At least mentioned the other utilities in zip.doc (zipcloak, ship, etc.),
  706. X    and documented upper case matching of names when using -d under MSDOS.
  707. X25. Fixed bug in MSDOS version: zip foo c:autoexec.bat wouldn't work.
  708. X26. Added hidden/system attribute bug to BUGS in zip.1
  709. X27. Fixed recognition of unship in ship when unship is in a path.
  710. X28. Added non-stream-LF VMS bug to zip.1 bug list.
  711. X29. Fixed bug in #23 above when path has dots.  Documented #23 in zip.1.
  712. X30. Show disclaimer only for -l, add -h and -l to zip utilities.
  713. X31. Applied Minix patches.
  714. X------------------------ ??? ??  1992   version 1.1 ------------------------
  715. X??? To be done. Should be the last version supporting shrink and implode.
  716. X
  717. X------------------------ Feb 17  1992   version 1.5 ------------------------
  718. X1.  pkzip 2.0 format (deflation) now supported
  719. X    Shrink and Implode left in zip 1.1 only for backward compatibility
  720. X
  721. X------------------------ Mar 25  1992   version 1.6 ------------------------
  722. X1.  zip can now be used as a filter in a pipe
  723. X2.  Optimized assembler code for MSDOS and OS/2
  724. X3.  encryption is now supported
  725. X4.  Better VMS support for various file formats other than Stream-LF
  726. X5.  Better OS/2 support
  727. X------------------------ Apr 24  1992   version 1.7a ------------------------
  728. X1.  On VMS, create new zip files in fixed length 512 format
  729. X2.  Call VMSmunch only if the zip file existed previously
  730. X3.  Avoid mktemp() and use simpler name for temporary file.
  731. X4.  Rename dir_os2.[ch] -> os2zip.[ch]
  732. X5.  On MSDOS, use fdopen() after setmode() in zip.c
  733. X    Added setmode() for stdin in zipup.c
  734. X6.  Do not split #if on two lines (some compilers don't like this)
  735. X7.  __MSDOS__ instead of __BORLANDC__ in crypt.c
  736. X8.  Added (char*) cast in deflate.c to avoid warning
  737. X9.  OS/2 support for storing file attributes in an extra field.
  738. X
  739. X------------------------ June 6  1992   version 1.8a ------------------------
  740. X1.  Fixed bug in tempname() for VMS
  741. X2.  Fixed type problems in zipup.c for gcc under VMS
  742. X3.  Added VMSmunch in vms subdirectory and updated makefile (descrip.mms)
  743. X4.  The extra field for OS/2 is now compressed (Kai Uwe Rommel)
  744. X5.  Added various fixes for djgcc (Onno van der Linden)
  745. X6.  Fixed long standing bug in wild() for MSDOS (Jon Saxton)
  746. X7.  Added support for ZIPOPT environment variable (Bill Davidsen
  747. X    and Antoine Verheijen).
  748. X8.  Fixed zipsplit bug for VMS (Greg Roelofs)
  749. X9.  Added fix for DEC OSF/1 (Kjetil W. J{\o}rgensen)
  750. X10. Added fix for ultrix on DECstation (Jonathan Kamens)
  751. X10. Added sysnopis for zipsplit, etc... in zip.1 (Jonathan Kamens)
  752. X11. Fixed MAILX problem for SysV in ship.c (Greg Roelofs)
  753. X12. Added Linux support (Humberto Ortiz-Zuazaga)
  754. X13. In makefile.os2, support for $(FP), masm 5.x, match.s (Greg & Kai)
  755. X14. Added -w-cln in makefile.bor to avoid warning (David Kirschbaum)
  756. X15. VMS echo suppression code incorporated (Greg Roelofs)
  757. X16. Added fix to match.asm if WSIZE != 32768
  758. X17. Create .exe files directly for target scodos (Bill Davidsen)
  759. X18. Fixed the -0 bug (compressed size was doubled)
  760. X19. Changed -- (read names from stdin) to -@ to reserve -- for undoing
  761. X    the effects of ZIPOPT
  762. X20. Create zip entries for directories with the -r option, so that
  763. X    directory attributes can be saved. (Kai Uwe Rommel)
  764. X
  765. X------------------------ June 17  1992   version 1.8b ------------------------
  766. X1.  Changed -s (Software license) to -L (license) to avoid clash
  767. X    with the old shrink option.
  768. X2.  read_buf declared as extern only in zip.h
  769. X3.  avoid warnings in zip.c for Turbo C: while ((ch = *s) != '\0'
  770. X4.  suppressed unused variables mem_inbuf and mem_outbuf in bits.c
  771. X5.  Speed up the search for start of zip structures (pksfx files)
  772. X6.  Allow updates of an empty pksfx file (original file was destroyed)
  773. X7.  Keep correct offsets for pksfx files
  774. X8.  On MSDOS, in2ex() was updating the input argument. Also, do not
  775. X    force upper case: keep the name as it was in the old zip file.
  776. X    This is important for -f. Similarly, force lower case in ex2in()
  777. X    on MSDOS, except when dosify (-k) is imposed. I kept however the
  778. X    old code under the flag FORCE_UPPER in case I goofed.
  779. X9.  When growing a zip file with -g and interrupting it, the whole file was
  780. X    lost. We now attempt to restore the previous state of the file.
  781. X10. "zip -fo jjj", where jjj is a non-existent zipfile, used to dump core.
  782. X    We now emit a warning.
  783. X11. More generally, we emit a warning for all options assuming the presence
  784. X    of a zip file (-d,-f,-u,-g) if the zip file did not exist or was empty.
  785. X    Idem for "zip -o jjj" on non-existent or empty zip file.
  786. X12. Copy also the extended local entry in zipcopy().
  787. X13. Updated zip.1 and vms/vms_zip.rnh to describe the new features.
  788. X14. Fixed bug in zipsplit (wrong offsets for all files but first)
  789. X15. Added match.s, optimized 386 version of longest_match() for Unix and
  790. X    32 bit OS/2 (with gas).
  791. X16. Added os2/match32.asm, optimized 386 version of longest_match() for
  792. X    32 bit OS/2 (for assemblers using Intel syntax). NOT TESTED YET.
  793. X17. Added "assume DS: DGROUP" in match.asm to allow SS_NEQ_DS even with MSC.
  794. X18. Added include <malloc.h> in tailor.h for Unix. This is required on
  795. X    16-bit Unix.
  796. X19. Use init_upper() in os2zip.[ch]
  797. X20. Switched back to old tempname(): the new one could overwrite an existing
  798. X    file, it ignored tempath, and it caused problems on VMS for files with a
  799. X    '.' in the name. Kept however the old code if NO_MKTEMP is defined.
  800. X21. Use 0x1 instead of (unsigned)1 in definition of HSIZE (one compiler
  801. X    does not like the cast in an array definition).
  802. X22. Include VMSmunch.h in zip.c
  803. X23. On VMS, zip -o screwed up all offsets in pksfx files
  804. X
  805. X------------------------ June 18  1992   version 1.8c ------------------------
  806. X1.  Added missing comma in revision.h
  807. X2.  invlocal doesn't work on Cray, use mktime instead (Greg Roelofs)
  808. X3.  On VMS, use ctx=stm only to read zipfiles, not input files.
  809. X4.  Undo change 21 above, which breaks even more compilers
  810. X5.  Include dos.h in util.c and fix trivial compilation errors
  811. X6.  Undo change 1 of 1.8b: -L already used for OS/2 (Steve Salisbury)
  812. X7.  Do not create a zip entry for directory "." (Greg Roelofs)
  813. X8.  Avoid core dump when -@ is given before the zip file (and do
  814. X    the right thing).
  815. X
  816. X------------------------ June 19  1992   version 1.8d ------------------------
  817. X1.  Force calloc to take unsigned values. (Problem with one 16 bit
  818. X    compiler on AT&T 6300).
  819. X2.  Fixed fileio.c for Convex (Bill Davidsen)
  820. X3.  util_ was missing for zipnote and zipsplit in make_vaxc.com (Glenn Andrews)
  821. X4.  Added warning in zip.1 and below (do not update encrypted files
  822. X    with pkzip 1.10).
  823. X5.  Fixed fix 12 of 1.8b. I drink too much. (Confused bit 1 with bit 8).
  824. X6.  Updated install.doc
  825. X7.  Fixed result type of os2 version of init_upper().
  826. X8.  Added makefile entry for AT&T 6300 (Peter Mauzey)
  827. X9.  Fixed typo in descrip.mms
  828. X10. Removed zipfile.c warning: shift count exceeds width of value shifted
  829. X11. Fix enormous bug in init_upper for VMS (upper stayed as zero)
  830. X
  831. X------------------------ June 23  1992   version 1.8e ------------------------
  832. X1.  Don't include malloc.h by default (does not exist on VMS)
  833. X2.  Define calloc for 16 bit systems (required for AT&T 6300)
  834. X3.  Simpler make_vaxc.com (Greg Roelofs)
  835. X4.  New vms/descrip.mms and fixes in zipfile.c (Igor)
  836. X5.  seekable() must be true for in-memory compression.
  837. X6.  Undefine S_IFLNK if NO_SYMLINK (problems with VMS and SCO)
  838. X7.  Include descrip.h only once in fileio.c (Mike Freeman)
  839. X8.  New os2/match32.asm (untested) and makefile.os2.
  840. X9.  Added dosflag in zlist and flist entries, to force MSDOS file
  841. X    attributes. It is set if dosify is set, or (under OS/2) for a file
  842. X    on a FAT file system which does not have a long name (Kai-Uwe).
  843. X10. Added GetFileTime on OS/2 to avoid core dump on bad dates (Kai-Uwe)
  844. X11. New vms.c supporting deflation of extra headers
  845. X
  846. X------------------------ June 24  1992   version 1.8f ------------------------
  847. X1.  Incorporated (finally!) Mac support. *Untested*. (James E. O'Dell)
  848. X2.  Another long awaited change: Atari ST. Also *untested*.
  849. X    (martin@atlantic.cs.unb.ca)
  850. X3.  New makefile.os2, as usual. (Kai-Uwe)
  851. X4.  Support for Watcom C in os2zip.c. *Not yet working*. (Kai-Uwe).
  852. X5.  I forgot to output the length for stored blocks...
  853. X
  854. X------------------------ June 29  1992   version 1.8g ------------------------
  855. X1.  New os2zip.c and makefile.os2 as usual.
  856. X2.  In the VMS makefiles, define the symbols systematically so that
  857. X    people won't forget to update them. (Fed up with the reports that
  858. X    zip does not accept parameters).
  859. X3.  Use -L for software License and -E for Extended attributes
  860. X4.  Added -F 1000 in makefile entry for scodos (Bill Davidsen)
  861. X5.  Replaced strcmp with namecmp in zip.c for check of zipfile name.
  862. X6.  New os2/match32.asm (still not working)
  863. X7.  Do not close stdin (check for null ifile in zipup.c).
  864. X8.  signal handlers for zip and zipcloak fixed to restore echo for VMS
  865. X9.  slightly cleaner VMS echo calls in fileio.c
  866. X10. stricmp missing from VMS zipsplit, zipnote:  since UTIL was unused for
  867. X    util.c, I used it to specify stricmp only; then I had to change some of
  868. X    the makefiles which previously used util_.* to use util.*, and I added
  869. X    util_.obj to OBJS and OBJN in all of the VMS makefiles. (Greg)
  870. X11. ifdef'd out the debugging commentary in vms.c (Greg)
  871. X12. new VMS makefile for use with (free) MAKE/VMS (Greg)
  872. X13. Eliminate some compiler warnings from BCC, MSC, gcc (Onno van der Linden)
  873. X14. Do not use MSDOS version of init_upper for djgpp (Onno van der Linden)
  874. X15. In msdos/makefile.gcc, added util_.o to OBJN and OBJS, and used asm version
  875. X    match.o (Onno van der Linden)
  876. X16. Added install target in makefile (Alvin Koh)
  877. X17. Default makefile entry is named 'all'.
  878. X18. fixes to vms.c for gcc (Igor)
  879. X19. Define S_IWRITE as S_IWUSR for Minix only (problem on X/OS) (Fulvio Marino)
  880. X20. Added xos makefile entry  (Fulvio Marino)
  881. X21. In VMS, files without an extension are now stored without the dot (Greg
  882. X    and Igor).
  883. X22. Save/restore ebx in match.s and match32.asm
  884. X23. Fixed MAX_DIST in match.s (the asm code produced different results
  885. X    than the C code)
  886. X24. Fixed the -b option: allow ENOTSAM instead of EXDEV (used by Turbo C).
  887. X25. Do not complain about zip files created on MSDOS with versions of zip
  888. X    above 1.0.
  889. X
  890. X------------------------ Aug 14  1992   version 1.9a ------------------------
  891. X1.  Changed -S to -L in help screen
  892. X2.  Do not declare chmod for aegis (George Grimes)
  893. X3.  Cleaner vms/make_gcc.com (Mike Freeman)
  894. X4.  Disabled built-in functions for Linux (Arnt Gulbrandsen)
  895. X5.  Added a description of the deflation algorithm in algorith.doc.
  896. X6.  Removed ship, now distributed separately.
  897. X7.  Added the CRC for in-memory compression. The extra-field format is now
  898. X    the official PKWare format (Kai-Uwe)
  899. X8.  On OS/2, force lower case names for FAT files if -k is not given. (Kai-Uwe)
  900. X9.  Allow coutry dependent mapping for upper to lower case. (Kai-Uwe)
  901. X10. Use namecmp instead of stricmp which was confusing. (Onno van der Linden)
  902. X11. Avoid some warnings in deflate.c (Onno van der Linden)
  903. X12. Avoid one warning in crypt.c, and distribute it separately.
  904. X13. Call init_upper() for all utilities and add util_.o in makefiles (Kai-Uwe)
  905. X
  906. X------------------------ Aug 18  1992   version 1.9b ------------------------
  907. X1.  Fixes for Windows NT (Dave Feinleib)
  908. X2.  Avoid two warnings for Ultrix (makefile and fileio.c)
  909. X3.  Finally removed the declaration of chmod(), which causes endless
  910. X    new patches for each new target.
  911. X4.  Allow -L for license in the utilities (zipsplit, zipnote, zipcloak).
  912. X5.  Mention funzip in zip.1.
  913. X6.  Untabify all sources files (for more reliable context diffs)
  914. X7.  Fix bug in trees.c dealing with bit length overflow.
  915. X8.  Fix bug in zipup.c when reading from stdin: if (ifile) does not
  916. X    produce the expected result.
  917. X9.  Avoid duplication of bug list in zip.1 and history.
  918. X10. Removed ship from zip.1.
  919. X
  920. X------------------------ Aug 20  1992   version 1.9 ------------------------
  921. X1.  Renamed the atari files to avoid name conflicts (for unzip -j).
  922. X2.  Don't tell 'use zip -L' in zipnote and zipsplit.
  923. X3.  Add a rule for util_.ojb in the msdos and atari makefiles
  924. X4.  Fixed compilation option for util_.obj in makefile.msc (msc 5.1 bug)
  925. X5.  Added the 'Where' file.
  926. X6.  More information about zip in Readme.
  927. X7.  Fixed install.doc.
  928. X8.  Fixed vms/vms_zip.rnh
  929. X9.  Fixed init_upper() in util.c and os2zip.c (Kai-Uwe)
  930. X
  931. X
  932. XThings to check or to be done (see also BUGS section in zip.1):
  933. X
  934. X- zip should not create 'stored' files with extended local headers
  935. X
  936. X- There is not (yet) a way to undo the effect of ZIPOPT
  937. X
  938. X- Under MSDOS, zip will find hidden and system files, but not set the
  939. X  attributes appropriately in the zip file so that unzip can restore them.
  940. X
  941. X- it is possible in weird cases to add a zipfile to itself
  942. X
  943. X- On OS/2, zip refuses to match some names, such as those beginning with an
  944. X  exclamation mark. Same for names starting with #, possibly more.
  945. END_OF_FILE
  946.   if test 49244 -ne `wc -c <'history'`; then
  947.     echo shar: \"'history'\" unpacked with wrong size!
  948.   fi
  949.   # end of 'history'
  950. fi
  951. if test ! -d 'mac' ; then
  952.     echo shar: Creating directory \"'mac'\"
  953.     mkdir 'mac'
  954. fi
  955. if test ! -d 'msdos' ; then
  956.     echo shar: Creating directory \"'msdos'\"
  957.     mkdir 'msdos'
  958. fi
  959. if test ! -d 'nt' ; then
  960.     echo shar: Creating directory \"'nt'\"
  961.     mkdir 'nt'
  962. fi
  963. if test ! -d 'os2' ; then
  964.     echo shar: Creating directory \"'os2'\"
  965.     mkdir 'os2'
  966. fi
  967. if test -f 'tailor.h' -a "${1}" != "-c" ; then 
  968.   echo shar: Will not clobber existing file \"'tailor.h'\"
  969. else
  970.   echo shar: Extracting \"'tailor.h'\" \(6875 characters\)
  971.   sed "s/^X//" >'tailor.h' <<'END_OF_FILE'
  972. X/* tailor.h -- Not copyrighted 1992 Mark Adler */
  973. X
  974. X/* const's are inconsistently used across ANSI libraries--kill for all
  975. X   header files. */
  976. X#ifndef __GO32__
  977. X#  define const
  978. X#endif
  979. X
  980. X
  981. X/* Define MSDOS for Turbo C as well as Microsoft C */
  982. X#ifdef __POWERC                 /* For Power C too */
  983. X#  define __TURBOC__
  984. X#endif /* __POWERC */
  985. X#if (defined(__TURBOC__) && !defined(MSDOS))
  986. X#  define MSDOS
  987. X#endif
  988. X
  989. X#ifdef ATARI_ST
  990. X#  undef MSDOS   /* avoid the MS-DOS specific includes */
  991. X#endif
  992. X
  993. X/* Use prototypes and ANSI libraries if _STDC__, or Microsoft or Borland C,
  994. X * or Silicon Graphics, or IBM C Set/2, or GNU gcc under emx.
  995. X */
  996. X#if (defined(__STDC__) || defined(MSDOS) || defined(sgi))
  997. X#  ifndef PROTO
  998. X#    define PROTO
  999. X#  endif /* !PROTO */
  1000. X#  define MODERN
  1001. X#endif /* MSDOS */
  1002. X
  1003. X#if (defined(__IBMC__) || defined(__EMX__) || defined(ATARI_ST))
  1004. X#  ifndef PROTO
  1005. X#    define PROTO
  1006. X#  endif /* !PROTO */
  1007. X#  define MODERN
  1008. X#endif
  1009. X
  1010. X
  1011. X#ifdef __IBMC__
  1012. X#  define S_IFMT 0xF000
  1013. X#endif /* __IBMC__ */
  1014. X
  1015. X#ifdef __EMX__
  1016. X#  define __32BIT__
  1017. X#endif /* __EMX__ */
  1018. X
  1019. X#ifdef __WATCOMC__
  1020. X#  define __32BIT__
  1021. X#endif
  1022. X
  1023. X#if (defined(__OS2__) && !defined(OS2))
  1024. X#  define OS2
  1025. X#endif
  1026. X
  1027. X
  1028. X/* Turn off prototypes if requested */
  1029. X#if (defined(NOPROTO) && defined(PROTO))
  1030. X#  undef PROTO
  1031. X#endif
  1032. X
  1033. X
  1034. X/* Used to remove arguments in function prototypes for non-ANSI C */
  1035. X#ifdef PROTO
  1036. X#  define OF(a) a
  1037. X#else /* !PROTO */
  1038. X#  define OF(a) ()
  1039. X#endif /* ?PROTO */
  1040. X
  1041. X
  1042. X/* Memory allocation. */
  1043. X#ifdef MACOS
  1044. X#  define DYN_ALLOC
  1045. X#endif
  1046. X#if (defined(MSDOS) && !defined(__GO32__) && !defined(WIN32))
  1047. X#  ifdef __TURBOC__
  1048. X#    include <alloc.h>
  1049. X#    define DYN_ALLOC
  1050. X     /* Turbo C 2.0 does not accept far static allocations in small model */
  1051. X     void far * fcalloc OF((unsigned items, unsigned size));
  1052. X#  else /* !__TURBOC__ */
  1053. X#    include <malloc.h>
  1054. X#    define farmalloc _fmalloc
  1055. X#    define farfree   _ffree
  1056. X#    define fcalloc(nitems,itemsize) halloc((long)(nitems),(itemsize))
  1057. X#  endif /* ?__TURBOC__ */
  1058. X#else /* !MSDOS */
  1059. X#  if defined(WIN32)
  1060. X#    include <malloc.h>
  1061. X#  endif
  1062. X#  ifdef far
  1063. X#    undef huge
  1064. X#    undef far
  1065. X#    undef near
  1066. X#  endif
  1067. X#  define huge
  1068. X#  define far
  1069. X#  define near
  1070. X#  define farmalloc malloc
  1071. X#  define farfree   free
  1072. X#  define fcalloc(items,size) calloc((unsigned)(items), (unsigned)(size))
  1073. X#  ifndef PROTO
  1074. X     extern char *calloc(); /* essential for 16 bit systems (AT&T 6300) */
  1075. X#  endif
  1076. X#endif /* ?MSDOS */
  1077. X
  1078. X
  1079. X#if (defined(OS2) && !defined(MSDOS))
  1080. X/* MSDOS is defined anyway with MS C 16-bit. So the block above works.
  1081. X * For the 32-bit compilers, MSDOS must not be defined in the block above. */
  1082. X#  define MSDOS
  1083. X/* inherit MS-DOS file system etc. stuff */
  1084. X#endif
  1085. X    
  1086. X
  1087. X/* Define MSVMS if either MSDOS or VMS defined */
  1088. X#if defined(MSDOS) || defined(VMS)
  1089. X#  define MSVMS
  1090. X#endif
  1091. X
  1092. X/* case mapping functions. case_map is used to ignore case in comparisons,
  1093. X * to_up is used to force upper case even on Unix (for dosify option).
  1094. X */
  1095. X#if defined(OS2) || defined(MSDOS) || defined(VMS)
  1096. X#  define case_map(c) upper[c]
  1097. X#  define to_up(c)    upper[c]
  1098. X#else
  1099. X#  define case_map(c) (c)
  1100. X#  define to_up(c)    ((c) >= 'a' && (c) <= 'z' ? (c)-'a'+'A' : (c))
  1101. X#endif
  1102. X
  1103. X/* Define void, voidp, and extent (size_t) */
  1104. X#include <stdio.h>
  1105. X#ifdef MODERN
  1106. X#  if (!defined(M_XENIX) && !(defined(__GNUC__) && defined(sun)))
  1107. X#    include <stddef.h>
  1108. X#  endif /* !M_XENIX */
  1109. X#  include <stdlib.h>
  1110. X   typedef size_t extent;
  1111. X   typedef void voidp;
  1112. X#else /* !MODERN */
  1113. X   typedef unsigned int extent;
  1114. X#  define void int
  1115. X   typedef char voidp;
  1116. X#endif /* ?MODERN */
  1117. X
  1118. X/* Get types and stat */
  1119. X#ifdef VMS
  1120. X#  include <types.h>
  1121. X#  include <stat.h>
  1122. X#else /* !VMS */
  1123. X#  ifdef MACOS
  1124. X#    include <types.h>
  1125. X#    include <stddef.h>
  1126. X#    include <Files.h>
  1127. X#    include <StandardFile.h>
  1128. X#    include <Think.h>
  1129. X#    include <LoMem.h>
  1130. X#    include <Pascal.h>
  1131. X#    include "macstat.h"
  1132. X#  else
  1133. X#    ifdef ATARI_ST
  1134. X#      include <ext.h>
  1135. X#      include <tos.h>
  1136. X#    else
  1137. X#      include <sys/types.h>
  1138. X#      include <sys/stat.h>
  1139. X#    endif
  1140. X#  endif
  1141. X#endif /* ?VMS */
  1142. X
  1143. X/* Some systems define S_IFLNK but do not support symbolic links */
  1144. X#if defined (S_IFLNK) && (defined(NO_SYMLINK) || defined(MACOS))
  1145. X#  undef S_IFLNK
  1146. X#endif
  1147. X
  1148. X/* Cheap fix for unlink on VMS */
  1149. X#ifdef VMS
  1150. X#  define unlink delete
  1151. X#endif /* VMS */
  1152. X
  1153. X
  1154. X/* For Pyramid */
  1155. X#ifdef pyr
  1156. X#  define strrchr rindex
  1157. X#  define ZMEM
  1158. X#endif /* pyr */
  1159. X
  1160. X
  1161. X/* File operations--use "b" for binary if allowed or fixed length 512 on VMS */
  1162. X#ifdef VMS
  1163. X#  define FOPR  "r","ctx=stm"
  1164. X#  define FOPM  "r+","ctx=stm","rfm=fix","mrs=512"
  1165. X#  define FOPW  "w","ctx=stm","rfm=fix","mrs=512"
  1166. X#else /* !VMS */
  1167. X#  ifdef MODERN
  1168. X#    define FOPR "rb"
  1169. X#    define FOPM "r+b"
  1170. X#    define FOPW "wb"
  1171. X#  else /* !MODERN */
  1172. X#    define FOPR "r"
  1173. X#    define FOPM "r+"
  1174. X#    define FOPW "w"
  1175. X#  endif /* ?MODERN */
  1176. X#endif /* VMS */
  1177. X
  1178. X/* Open the old zip file in exclusive mode if possible (to avoid adding
  1179. X * zip file to itself).
  1180. X */
  1181. X#ifdef OS2
  1182. X#  define FOPR_EX FOPM
  1183. X#else
  1184. X#  define FOPR_EX FOPR
  1185. X#endif
  1186. X
  1187. X/* Define this symbol if your target allows access to unaligned data.
  1188. X * This is not mandatory, just a speed optimization. The compressed
  1189. X * output is strictly identical.
  1190. X */
  1191. X#if defined(MSDOS) || defined(i386) || defined(mc68020) || defined(vax)
  1192. X#   define UNALIGNED_OK
  1193. X#endif
  1194. X
  1195. X
  1196. X/* Under MSDOS we may run out of memory when processing a large number
  1197. X * of files. Compile with MEDIUM_MEM to reduce the memory requirements or
  1198. X * with SMALL_MEM to use as little memory as possible.
  1199. X */
  1200. X#ifdef SMALL_MEM
  1201. X#   define CBSZ 2048 /* buffer size for copying files */
  1202. X#   define ZBSZ 2048 /* buffer size for temporary zip file */
  1203. X#else
  1204. X# ifdef MEDIUM_MEM
  1205. X#   define CBSZ 8192
  1206. X#   define ZBSZ 8192
  1207. X# else
  1208. X#  if defined(OS2) && !defined(M_I86SM)
  1209. X#   define CBSZ 0xE000
  1210. X#   define ZBSZ 0x7F00
  1211. X    /* The C library of some compilers does not allow a buffer size > 32K */
  1212. X#  else
  1213. X#   define CBSZ 16384
  1214. X#   define ZBSZ 16384
  1215. X#  endif
  1216. X# endif
  1217. X#endif
  1218. X
  1219. X#ifdef ATARI_ST
  1220. X#  define MSDOS
  1221. X#  define MSVMS
  1222. X#  ifndef O_BINARY
  1223. X#    define O_BINARY 0
  1224. X#  endif
  1225. X#  ifndef S_IFMT
  1226. X#    define S_IFMT        (S_IFCHR|S_IFREG|S_IFDIR)
  1227. X#  endif
  1228. X
  1229. X/* a whole bunch of functions needs Tos '\\' filnames
  1230. X * instead of '/',  the translation functions are in fileio.c:
  1231. X */
  1232. X#  define unlink    st_unlink
  1233. X#  define chmod     st_chmod
  1234. X#  define mktemp    st_mktemp
  1235. X#  define fopen     st_fopen
  1236. X#  define open      st_open
  1237. X#  define SSTAT     st_stat
  1238. X#  define findfirst st_findfirst
  1239. X#  define link      st_rename
  1240. X#  define rmdir     st_rmdir
  1241. X
  1242. X  int st_unlink    OF((char *));
  1243. X  int st_chmod     OF((char *, int));
  1244. X  char *st_mktemp  OF((char *));
  1245. X  FILE *st_fopen   OF((char *, char *));
  1246. X  int st_open      OF((char *, int));
  1247. X  int st_stat      OF((char *, struct stat *));
  1248. X  int st_findfirst OF((char *, struct ffblk *, int));
  1249. X  int st_rename    OF((char *, char *));
  1250. X  int st_rmdir     OF((char *));
  1251. X#else
  1252. X#  define SSTAT      stat
  1253. X#endif
  1254. X   
  1255. X/* end of tailor.h */
  1256. END_OF_FILE
  1257.   if test 6875 -ne `wc -c <'tailor.h'`; then
  1258.     echo shar: \"'tailor.h'\" unpacked with wrong size!
  1259.   fi
  1260.   # end of 'tailor.h'
  1261. fi
  1262. if test ! -d 'vms' ; then
  1263.     echo shar: Creating directory \"'vms'\"
  1264.     mkdir 'vms'
  1265. fi
  1266. echo shar: End of archive 1 \(of 11\).
  1267. cp /dev/null ark1isdone
  1268. MISSING=""
  1269. for I in 1 2 3 4 5 6 7 8 9 10 11 ; do
  1270.     if test ! -f ark${I}isdone ; then
  1271.     MISSING="${MISSING} ${I}"
  1272.     fi
  1273. done
  1274. if test "${MISSING}" = "" ; then
  1275.     echo You have unpacked all 11 archives.
  1276.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  1277. else
  1278.     echo You still must unpack the following archives:
  1279.     echo "        " ${MISSING}
  1280. fi
  1281. exit 0
  1282. exit 0 # Just in case...
  1283. Newsgroups: comp.sources.misc
  1284. From: zip-bugs@cs.ucla.edu (Info-ZIP group)
  1285. Subject:  v31i094:  zip19 - Info-ZIP portable Zip, version 1.9, Part02/11
  1286. Message-ID: <1992Aug23.064513.28972@sparky.imd.sterling.com>
  1287. X-Md4-Signature: cf491d96f8441d411222c18f4edf15b0
  1288. Date: Sun, 23 Aug 1992 06:45:13 GMT
  1289. Approved: kent@sparky.imd.sterling.com
  1290.  
  1291. Submitted-by: zip-bugs@cs.ucla.edu (Info-ZIP group)
  1292. Posting-number: Volume 31, Issue 94
  1293. Archive-name: zip19/part02
  1294. Supersedes: zip: Volume 23, Issue 88-96
  1295. Environment: UNIX, VMS, OS/2, MS-DOS, MACINTOSH, WIN-NT, LINUX, MINIX, XOS, !AMIGA, ATARI, symlink, SGI, DEC, Cray, Convex, Amdahl, Sun, PC
  1296.  
  1297. #! /bin/sh
  1298. # This is a shell archive.  Remove anything before this line, then feed it
  1299. # into a shell via "sh file" or similar.  To overwrite existing files,
  1300. # type "sh file -c".
  1301. # The tool that generated this appeared in the comp.sources.unix newsgroup;
  1302. # send mail to comp-sources-unix@uunet.uu.net if you want that tool.
  1303. # Contents:  atari/stzip.lnk fileio.c
  1304. # Wrapped by kent@sparky on Sun Aug 23 01:00:42 1992
  1305. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  1306. echo If this archive is complete, you will see the following message:
  1307. echo '          "shar: End of archive 2 (of 11)."'
  1308. if test -f 'atari/stzip.lnk' -a "${1}" != "-c" ; then 
  1309.   echo shar: Will not clobber existing file \"'atari/stzip.lnk'\"
  1310. else
  1311.   echo shar: Extracting \"'atari/stzip.lnk'\" \(180 characters\)
  1312.   sed "s/^X//" >'atari/stzip.lnk' <<'END_OF_FILE'
  1313. X\TC\lib\c0.o
  1314. Xzip.o
  1315. X\TC\lib\tcstdlib.lib
  1316. Xatari.o
  1317. Xzipfile.o
  1318. Xzipup.o
  1319. Xfileio.o
  1320. Xutil.o
  1321. Xglobals.o
  1322. Xdeflate.o
  1323. Xtrees.o
  1324. Xbits.o
  1325. X\TC\lib\tcstdlib.lib
  1326. X\TC\lib\tcextlib.lib
  1327. X\TC\lib\tctoslib.lib
  1328. END_OF_FILE
  1329.   if test 180 -ne `wc -c <'atari/stzip.lnk'`; then
  1330.     echo shar: \"'atari/stzip.lnk'\" unpacked with wrong size!
  1331.   fi
  1332.   # end of 'atari/stzip.lnk'
  1333. fi
  1334. if test -f 'fileio.c' -a "${1}" != "-c" ; then 
  1335.   echo shar: Will not clobber existing file \"'fileio.c'\"
  1336. else
  1337.   echo shar: Extracting \"'fileio.c'\" \(57097 characters\)
  1338.   sed "s/^X//" >'fileio.c' <<'END_OF_FILE'
  1339. X/*
  1340. X
  1341. X Copyright (C) 1990-1992 Mark Adler, Richard B. Wales, Jean-loup Gailly,
  1342. X Kai Uwe Rommel and Igor Mandrichenko.
  1343. X Permission is granted to any individual or institution to use, copy, or
  1344. X redistribute this software so long as all of the original files are included
  1345. X unmodified, that it is not sold for profit, and that this copyright notice
  1346. X is retained.
  1347. X
  1348. X*/
  1349. X
  1350. X/*
  1351. X *  fileio.c by Mark Adler.
  1352. X */
  1353. X
  1354. X#include "zip.h"
  1355. X
  1356. X#include <time.h>
  1357. X
  1358. X#ifdef WIN32
  1359. X#  include <sys/utime.h>
  1360. X#  include <windows.h> /* for findfirst/findnext */
  1361. X#endif
  1362. X
  1363. X#ifdef MACOS
  1364. X#  define EXDEV 1
  1365. X#endif
  1366. X
  1367. X#ifdef OSF
  1368. X#  define EXDEV 18    /* avoid a bug in the DEC OSF/1 header files. */
  1369. X#else
  1370. X#  include <errno.h>
  1371. X#endif
  1372. X
  1373. X#ifdef MINIX
  1374. X#  ifdef S_IWRITE
  1375. X#    undef S_IWRITE
  1376. X#  endif /* S_IWRITE */
  1377. X#  define S_IWRITE S_IWUSR
  1378. X#endif /* S_IWUSR */
  1379. X
  1380. X#ifdef ATARI_ST
  1381. X#  undef MSDOS
  1382. X#endif
  1383. X
  1384. X#ifdef MSDOS
  1385. X#  include <io.h>
  1386. X#  if (defined(__TURBOC__) || defined(__GO32__))
  1387. X#    include <dir.h>
  1388. X#  else /* !__TURBOC__ */
  1389. X#    if !defined(__EMX__) && !defined(__WATCOMC__)
  1390. X#      include <direct.h>
  1391. X#    endif
  1392. X#  endif /* ?__TURBOC__ */
  1393. X#  define link rename
  1394. X#  ifdef OS2
  1395. X#    define MATCH shmatch
  1396. X#  else /* !OS2 */
  1397. X#    define MATCH dosmatch
  1398. X#  endif /* ?OS2 */
  1399. X#else /* !MSDOS */
  1400. X   extern int errno;    /* error number from system functions */
  1401. X#  ifdef VMS
  1402. X#    define RMDIR
  1403. X#    define link rename
  1404. X#    include "VMSmunch.h"
  1405. X#  endif /* VMS */
  1406. X#  ifdef MACOS
  1407. X#    define link rename
  1408. X#    define mktemp tmpnam
  1409. X#  endif
  1410. X#  define MATCH shmatch
  1411. X#endif /* ?MSDOS */
  1412. X
  1413. X#ifdef ATARI_ST
  1414. X#  define MSDOS 1
  1415. X#endif
  1416. X
  1417. X#ifdef UTS
  1418. X#  define RMDIR
  1419. X#endif /* UTS */
  1420. X
  1421. X
  1422. X/* Extra malloc() space in names for cutpath() */
  1423. X#ifdef VMS
  1424. X#  define PAD 3         /* may have to change .FOO] to ]FOO.DIR */
  1425. X#else /* !VMS */
  1426. X#  define PAD 0
  1427. X#endif /* ?VMS */
  1428. X
  1429. X
  1430. X/* For now, assume DIRENT implies System V implies TERMIO */
  1431. X#if defined(DIRENT) && !defined(MINIX) && !defined(TERMIO)
  1432. X#  define TERMIO
  1433. X#endif
  1434. X
  1435. X
  1436. X#ifdef CRYPT
  1437. X#  ifdef MSVMS
  1438. X#    ifdef MSDOS
  1439. X#      ifdef __EMX__
  1440. X#        define getch() _read_kbd(0, 1, 0)
  1441. X#      else
  1442. X#        ifdef __GO32__
  1443. X#          include <pc.h>
  1444. X#          define getch() getkey()
  1445. X#        else
  1446. X#          include <conio.h>
  1447. X#        endif
  1448. X#      endif
  1449. X#    else /* !MSDOS */
  1450. X#      define getch() getc(stderr)
  1451. X#      define echoff(f) echo(0)   /* for echo control */
  1452. X#      define echon()   echo(1)
  1453. X#      include <iodef.h>
  1454. X#      include <ttdef.h>
  1455. X#      if !defined(SS$_NORMAL)
  1456. X#        define SS$_NORMAL 1   /* only thing we need from <ssdef.h> */
  1457. X#      endif
  1458. X#    endif /* ?MSDOS */
  1459. X#  else /* !MSVMS */
  1460. X#    ifdef TERMIO       /* Amdahl, Cray, all SysV? */
  1461. X#      ifdef CONVEX
  1462. X#        include <sys/termios.h>
  1463. X#        include <sgtty.h>
  1464. X#        define O_BINARY 0
  1465. X#      else /* !CONVEX */
  1466. X#        ifdef LINUX 
  1467. X#          include <termios.h>
  1468. X#        else /* !LINUX */
  1469. X#          include <sys/termio.h>
  1470. X#        endif /* ?LINUX */
  1471. X#        define sgttyb termio
  1472. X#        define sg_flags c_lflag
  1473. X         int ioctl OF((int, int, voidp *));
  1474. X#      endif /* ?CONVEX */
  1475. X#      define GTTY(f,s) ioctl(f,TCGETA,s)
  1476. X#      define STTY(f,s) ioctl(f,TCSETAW,s)
  1477. X#    else /* !TERMIO */
  1478. X#      ifndef MINIX
  1479. X#        include <sys/ioctl.h>
  1480. X#      endif /* !MINIX */
  1481. X#      include <sgtty.h>
  1482. X       int gtty OF((int, struct sgttyb *));
  1483. X       int stty OF((int, struct sgttyb *));
  1484. X#      define GTTY gtty
  1485. X#      define STTY stty
  1486. X#    endif /* ?TERMIO */
  1487. X     int isatty OF((int));
  1488. X     char *ttyname OF((int));
  1489. X     int open OF((char *, int, ...));
  1490. X     int close OF((int));
  1491. X     int read OF((int, voidp *, int));
  1492. X#  endif /* ?MSVMS */
  1493. X#endif /* ?CRYPT */
  1494. X
  1495. X#ifdef VMS
  1496. X#  include <descrip.h>
  1497. X#  include <rms.h>
  1498. X#endif
  1499. X
  1500. X/* For directory access. (This is getting rather messy. Cleanup
  1501. X * scheduled for version 17.9.)
  1502. X */
  1503. X#ifndef UTIL
  1504. X
  1505. X#ifdef SYSV                     /* use readdir()  */
  1506. X#  include <dirent.h>
  1507. X#  define dstrm DIR
  1508. X#  define direct dirent
  1509. X#else
  1510. X
  1511. X#ifdef DIRENT                   /* use getdents() */
  1512. X#  if defined(MINIX) || defined(OSF)
  1513. X#    include <dirent.h>
  1514. X#  else /* !MINIX */
  1515. X#    include <sys/dirent.h>
  1516. X#  endif /* ?MINIX */
  1517. X#  define direct dirent
  1518. X#  ifdef MINIX
  1519. X     int getdents OF((int, char *, unsigned));
  1520. X#  else /* !MINIX */
  1521. X     int getdents OF((int, char *, int));
  1522. X#  endif /* ?MINIX */
  1523. X#  define DBSZ 4096     /* This has to be bigger than a directory block */
  1524. X   typedef struct {     /* directory stream buffer */
  1525. X     int f;             /* file descriptor for the directory "file" */
  1526. X     char *p;           /* pointer to next entry in buffer */
  1527. X     char *q;           /* pointer after end of buffer contents */
  1528. X     char b[DBSZ];              /* buffer */
  1529. X   } dstrm;
  1530. X
  1531. X#else /* !DIRENT */             /* use opendir(), etc. */
  1532. X#  if defined(CONVEX) || defined(ultrix)
  1533. X#    include <dirent.h>
  1534. X#    ifdef direct
  1535. X#      undef direct /* ultrix 4.2, at least if !__POSIX */
  1536. X#    endif
  1537. X#    define direct dirent
  1538. X#  endif /* CONVEX || ultrix */
  1539. X#  ifdef NDIR
  1540. X#    include "ndir.h"           /* for HPUX */
  1541. X#  else /* !NDIR */
  1542. X#    ifdef MSDOS
  1543. X#     ifdef OS2
  1544. X#      include "os2zip.h"
  1545. X#     else /* !OS2 */
  1546. X#      ifndef ATARI_ST
  1547. X#        include <dos.h>
  1548. X#      endif
  1549. X#      if (defined(__TURBOC__) || defined(__GO32__))
  1550. X#        define FATTR           FA_HIDDEN+FA_SYSTEM+FA_DIREC
  1551. X#        define FFIRST(n,d)     findfirst(n,(struct ffblk *)d,FATTR)
  1552. X#        define FNEXT(d)        findnext((struct ffblk *)d)
  1553. X#      else /* !__TURBOC__ */
  1554. X#        define FATTR           _A_HIDDEN+_A_SYSTEM+_A_SUBDIR
  1555. X#        define FFIRST(n,d)     _dos_findfirst(n,FATTR,(struct find_t *)d)
  1556. X#        define FNEXT(d)        _dos_findnext((struct find_t *)d)
  1557. X#      endif /* ?__TURBOC__ */
  1558. X       typedef struct direct {
  1559. X         char d_reserved[30];
  1560. X         char d_name[13];
  1561. X     int d_first;
  1562. X#ifdef WIN32
  1563. X     HANDLE d_hFindFile;
  1564. X#endif
  1565. X       } DIR;
  1566. X#     endif /* ?OS2 */
  1567. X#    else /* !MSDOS */
  1568. X#      ifdef VMS
  1569. X#        include <ssdef.h>
  1570. X         typedef struct direct {
  1571. X             int d_wild;                /* flag for wildcard vs. non-wild */
  1572. X             struct FAB fab;
  1573. X             struct NAM nam;
  1574. X             char d_qualwildname[NAM$C_MAXRSS + 1];
  1575. X             char d_name[NAM$C_MAXRSS + 1];
  1576. X         } DIR;
  1577. X#      else /* !VMS */
  1578. X#        ifdef MACOS
  1579. X           typedef struct direct {
  1580. X             int d_wild;                /* flag for wildcard vs. non-wild */
  1581. X             char *d_name;
  1582. X          } DIR;
  1583. X#        endif
  1584. X#        ifdef M_XENIX
  1585. X#          include <sys/ndir.h>
  1586. X#        else /* !M_XENIX */
  1587. X#          include <sys/dir.h>
  1588. X#        endif /* ?M_XENIX */
  1589. X#        ifdef NODIR                    /* for AT&T 3B1 */
  1590. X#          define dirent direct
  1591. X           typedef FILE DIR;
  1592. X#          define dstrm DIR
  1593. X#        endif /* NODIR */
  1594. X#      endif /* ?VMS */
  1595. X#    endif /* ?MSDOS */
  1596. X#  endif /* ?NDIR */
  1597. X#  define dstrm DIR
  1598. X#  ifndef NODIR
  1599. X     DIR *opendir OF((char *));
  1600. X#  endif /* !NODIR */
  1601. X#  ifndef CONVEX
  1602. X     struct direct *readdir OF((DIR *));
  1603. X#  endif /* !CONVEX */
  1604. X#endif /* ?DIRENT */
  1605. X#endif /* ?SYSV */
  1606. X#endif /* !UTIL */
  1607. X
  1608. X
  1609. X/* Library functions not in (most) header files */
  1610. X
  1611. X#if defined(__IBMC__) || defined(__WATCOMC__)
  1612. X#  define NO_MKTEMP
  1613. X#endif
  1614. Xchar *mktemp OF((char *));
  1615. X
  1616. X#ifdef __GO32__
  1617. X  char *strlwr OF((char *));
  1618. X#else
  1619. X  int link OF((char *, char *));
  1620. X  int unlink OF((char *));
  1621. X# if defined(MSDOS)
  1622. X   int chmod OF((char *, int));
  1623. X   /* For many targets, chmod is already defined by sys/stat.h, and second
  1624. X    * parameter is an unsigned long.
  1625. X    */
  1626. X# endif
  1627. X#endif
  1628. X
  1629. X
  1630. X#ifndef UTIL    /* the companion #endif is a bit of ways down ... */
  1631. X
  1632. X#ifndef __TURBOC__
  1633. X   int utime OF((char *, time_t *));
  1634. X#endif /* !__TURBOC__ */
  1635. X#ifndef MSDOS
  1636. X   int open OF((char *, int, ...));
  1637. X   int close OF((int));
  1638. X#  ifndef RMDIR
  1639. X     int rmdir OF((char *));
  1640. X#  endif /* !RMDIR */
  1641. X#endif /* !MSDOS */
  1642. X
  1643. X
  1644. X/* Local globals (kinda like "military intelligence" or "broadcast quality") */
  1645. Xlocal int exflag = 0;           /* Exclude flag */
  1646. X
  1647. X#ifdef VMS
  1648. X  typedef int statime;
  1649. X#else /* !VMS */
  1650. X  typedef time_t statime;
  1651. X#endif /* ?VMS */
  1652. X
  1653. X/* Local functions */
  1654. X#ifdef PROTO
  1655. X#  ifdef VMS
  1656. X     local void vms_wild(char *, dstrm *);
  1657. X#  endif /* VMS */
  1658. X#  ifdef DIRENT
  1659. X     local dstrm *opend(char *);
  1660. X     local void closed(dstrm *);
  1661. X#  endif /* DIRENT */
  1662. X   local char *readd(dstrm *);
  1663. X   local int fqcmp(voidp *, voidp *);
  1664. X   local int fqcmpz(voidp *, voidp *);
  1665. X   local char *last(char *);
  1666. X   local char *msname(char *);
  1667. X#  ifdef VMS
  1668. X     local char *strlower(char *);
  1669. X     local char *strupper(char *);
  1670. X#  endif /* VMS */
  1671. X   local char *ex2in(char *, int *);
  1672. X   local int newname(char *);
  1673. X   local void inctime(struct tm *);
  1674. X   local ulg unix2dostime(statime *);
  1675. X#  if !defined(__TURBOC__) && !defined(OS2) && !defined(__GO32__)
  1676. X     local int cmptime(struct tm *, struct tm *);
  1677. X     local time_t invlocal(struct tm *);
  1678. X#  endif /* !__TURBOC__ */
  1679. X#endif /* PROTO */
  1680. X
  1681. X
  1682. X#if defined(MSDOS) && !defined(OS2)
  1683. Xdstrm *opendir(n)
  1684. Xchar *n;                /* directory to open */
  1685. X/* Start searching for files in the MSDOS directory n */
  1686. X{
  1687. X  dstrm *d;             /* malloc'd return value */
  1688. X  char *p;              /* malloc'd temporary string */
  1689. X
  1690. X  if ((d = (dstrm *)malloc(sizeof(dstrm))) == NULL ||
  1691. X      (p = malloc(strlen(n) + 5)) == NULL)
  1692. X    return NULL;
  1693. X  strcat(strcpy(p, n), "/*.*");
  1694. X#ifdef WIN32
  1695. X  {
  1696. X  WIN32_FIND_DATA fd;
  1697. X  DWORD dwAttr;
  1698. X  BOOL bAttr;
  1699. X
  1700. X  if ((HANDLE)0xFFFFFFFF == (d->d_hFindFile = FindFirstFile(p, &fd)))
  1701. X    {
  1702. X    free((voidp *)p);
  1703. X    return NULL;
  1704. X    }
  1705. X  else
  1706. X    strcpy(d->d_name, fd.cFileName);
  1707. X  if (-1 != (dwAttr = GetFileAttributes(fd.cFileName)))
  1708. X    {
  1709. X    bAttr = FALSE;
  1710. X    if (FILE_ATTRIBUTE_SYSTEM == (dwAttr & FILE_ATTRIBUTE_SYSTEM))
  1711. X    bAttr = TRUE;
  1712. X    if (FILE_ATTRIBUTE_HIDDEN == (dwAttr & FILE_ATTRIBUTE_HIDDEN))
  1713. X    bAttr = TRUE;
  1714. X    if (FILE_ATTRIBUTE_DIRECTORY == (dwAttr & FILE_ATTRIBUTE_DIRECTORY))
  1715. X    bAttr = TRUE;
  1716. X    if (!bAttr)
  1717. X    {
  1718. X    free ((voidp *)p);
  1719. X    free ((void *) d);
  1720. X    return NULL;
  1721. X    }
  1722. X    }
  1723. X
  1724. X  }
  1725. X#else
  1726. X  if (FFIRST(p, d))
  1727. X  {
  1728. X    free((voidp *)p);
  1729. X    return NULL;
  1730. X  }
  1731. X  free((voidp *)p);
  1732. X#endif
  1733. X  d->d_first = 1;
  1734. X  return d;
  1735. X}
  1736. X
  1737. Xstruct direct *readdir(d)
  1738. Xdstrm *d;               /* directory stream to read from */
  1739. X/* Return pointer to first or next directory entry, or NULL if end. */
  1740. X{
  1741. X  if (d->d_first)
  1742. X    d->d_first = 0;
  1743. X  else
  1744. X#ifdef WIN32
  1745. X    {
  1746. X    WIN32_FIND_DATA fd;
  1747. X
  1748. X    if (!FindNextFile(d->d_hFindFile, &fd))
  1749. X    return NULL;
  1750. X    else
  1751. X    strcpy(d->d_name, fd.cFileName);
  1752. X    }
  1753. X#else /* !WIN32 */
  1754. X    if (FNEXT(d))
  1755. X      return NULL;
  1756. X#endif
  1757. X  return (struct direct *)d;
  1758. X}
  1759. X#  define closedir free
  1760. X
  1761. X#endif /* MSDOS && !OS2 */
  1762. X
  1763. X
  1764. X#ifdef VMS
  1765. X
  1766. X/*---------------------------------------------------------------------------
  1767. X
  1768. X    _vms_findfirst() and _vms_findnext(), based on public-domain DECUS C
  1769. X    fwild() and fnext() routines (originally written by Martin Minow, poss-
  1770. X    ibly modified by Jerry Leichter for bintnxvms.c), were written by Greg
  1771. X    Roelofs and are still in the public domain.  Routines approximate the
  1772. X    behavior of MS-DOS (MSC and Turbo C) findfirst and findnext functions.
  1773. X
  1774. X  ---------------------------------------------------------------------------*/
  1775. Xlocal void vms_wild(p, d)
  1776. Xchar *p;
  1777. Xdstrm *d;
  1778. X{
  1779. X  /*
  1780. X   * Do wildcard setup
  1781. X   */
  1782. X  /* set up the FAB and NAM blocks. */
  1783. X  d->fab = cc$rms_fab;             /* initialize fab */
  1784. X  d->nam = cc$rms_nam;             /* initialize nam */
  1785. X
  1786. X  d->fab.fab$l_nam = &d->nam;           /* fab -> nam */
  1787. X  d->fab.fab$l_fna = p;                 /* argument wild name */
  1788. X  d->fab.fab$b_fns = strlen(p);         /* length */
  1789. X
  1790. X  d->nam.nam$l_esa = d->d_qualwildname; /* qualified wild name */
  1791. X  d->nam.nam$b_ess = NAM$C_MAXRSS;      /* max length */
  1792. X  d->nam.nam$l_rsa = d->d_name;         /* matching file name */
  1793. X  d->nam.nam$b_rss = NAM$C_MAXRSS;      /* max length */
  1794. X
  1795. X  /* parse the file name */
  1796. X  if (sys$parse(&d->fab) != RMS$_NORMAL)
  1797. X    return;
  1798. X  /* Does this replace d->fab.fab$l_fna with a new string in its own space?
  1799. X     I sure hope so, since p is free'ed before this routine returns. */
  1800. X
  1801. X  /* have qualified wild name (i.e., disk:[dir.subdir]*.*); null-terminate
  1802. X   * and set wild-flag */
  1803. X  d->d_qualwildname[d->nam.nam$b_esl] = '\0';
  1804. X  d->d_wild = (d->nam.nam$l_fnb & NAM$M_WILDCARD)? 1 : 0;   /* not used... */
  1805. X#ifdef DEBUG
  1806. X  printf("  incoming wildname:  %s\n", p);
  1807. X  printf("  qualified wildname:  %s\n", d->d_qualwildname);
  1808. X#endif /* DEBUG */
  1809. X}
  1810. X
  1811. Xdstrm *opendir(n)
  1812. Xchar *n;                /* directory to open */
  1813. X/* Start searching for files in the VMS directory n */
  1814. X{
  1815. X  char *c;              /* scans VMS path */
  1816. X  dstrm *d;             /* malloc'd return value */
  1817. X  int m;                /* length of name */
  1818. X  char *p;              /* malloc'd temporary string */
  1819. X
  1820. X  if ((d = (dstrm *)malloc(sizeof(dstrm))) == NULL ||
  1821. X      (p = malloc((m = strlen(n)) + 4)) == NULL)
  1822. X    return NULL;
  1823. X  /* Directory may be in form "[DIR.SUB1.SUB2]" or "[DIR.SUB1]SUB2.DIR;1".
  1824. X     If latter, convert to former. */
  1825. X  if (m > 0  &&  *(c = strcpy(p,n)+m-1) != ']')
  1826. X  {
  1827. X    while (--c > p  &&  *c != ';')
  1828. X      ;
  1829. X    if (c-p < 5  ||  strncmp(c-4, ".DIR", 4))
  1830. X    {
  1831. X      free((voidp *)d);  free((voidp *)p);
  1832. X      return NULL;
  1833. X    }
  1834. X    c -= 3;
  1835. X    *c-- = '\0';        /* terminate at "DIR;#" */
  1836. X    *c = ']';           /* "." --> "]" */
  1837. X    while (c > p  &&  *--c != ']')
  1838. X      ;
  1839. X    *c = '.';           /* "]" --> "." */
  1840. X  }
  1841. X  strcat(p, "*.*");
  1842. X  vms_wild(p, d);       /* set up wildcard */
  1843. X  free((voidp *)p);
  1844. X  return d;
  1845. X}
  1846. X
  1847. Xstruct direct *readdir(d)
  1848. Xdstrm *d;               /* directory stream to read from */
  1849. X/* Return pointer to first or next directory entry, or NULL if end. */
  1850. X{
  1851. X  int r;                /* return code */
  1852. X
  1853. X  do {
  1854. X    d->fab.fab$w_ifi = 0;       /* internal file index:  what does this do? */
  1855. X
  1856. X    /* get next match to possible wildcard */
  1857. X    if ((r = sys$search(&d->fab)) == RMS$_NORMAL)
  1858. X    {
  1859. X        d->d_name[d->nam.nam$b_rsl] = '\0';   /* null terminate */
  1860. X        return (struct direct *)d;   /* OK */
  1861. X    }
  1862. X  } while (r == RMS$_PRV);
  1863. X  return NULL;
  1864. X}
  1865. X#  define closedir free
  1866. X#endif /* VMS */
  1867. X
  1868. X
  1869. X#ifdef NODIR                    /* for AT&T 3B1 */
  1870. X/*
  1871. X**  Apparently originally by Rich Salz.
  1872. X**  Cleaned up and modified by James W. Birdsall.
  1873. X*/
  1874. X
  1875. X#  define opendir(path) fopen(path, "r")
  1876. Xstruct direct *readdir(dirp)
  1877. XDIR *dirp;
  1878. X{
  1879. X  static struct direct entry;
  1880. X
  1881. X  if (dirp == NULL) 
  1882. X    return NULL;
  1883. X  for (;;)
  1884. X    if (fread (&entry, sizeof (struct direct), 1, dirp) == 0) 
  1885. X      return NULL;
  1886. X    else if (entry.d_ino) 
  1887. X      return (&entry);
  1888. X} /* end of readdir() */
  1889. X
  1890. X#  define closedir(dirp) fclose(dirp)
  1891. X#endif /* NODIR */
  1892. X
  1893. X
  1894. X#ifdef DIRENT
  1895. Xlocal dstrm *opend(n)
  1896. Xchar *n;                /* directory name to open */
  1897. X/* Open the directory *n, returning a pointer to an allocated dstrm, or
  1898. X   NULL if error. */
  1899. X{
  1900. X  dstrm *d;             /* pointer to malloc'ed directory stream */
  1901. X
  1902. X  if ((d = (dstrm *)malloc(sizeof(dstrm))) == NULL)
  1903. X    return NULL;
  1904. X  if ((d->f = open(n, 0, 0)) < 0)               /* open directory */
  1905. X    return NULL;
  1906. X  d->p = d->q = d->b;                           /* buffer is empty */
  1907. X  return d;
  1908. X}
  1909. X#else /* !DIRENT */
  1910. X#  define opend opendir                         /* just use opendir() */
  1911. X#endif /* ?DIRENT */
  1912. X
  1913. X
  1914. Xlocal char *readd(d)
  1915. Xdstrm *d;               /* directory stream to read from */
  1916. X/* Return a pointer to the next name in the directory stream d, or NULL if
  1917. X   no more entries or an error occurs. */
  1918. X{
  1919. X  struct direct *e;     /* directory entry read */
  1920. X
  1921. X#ifdef DIRENT
  1922. X  int n;                /* number of entries read by getdents */
  1923. X
  1924. X  if (d->p >= d->q)                             /* if empty, fill buffer */
  1925. X    if ((n = getdents(d->f, d->b, DBSZ)) <= 0)
  1926. X      return NULL;
  1927. X    else
  1928. X      d->q = n + (d->p = d->b);
  1929. X  e = (struct direct *)(d->p);                  /* point to entry */
  1930. X  d->p += ((struct direct *)(d->p))->d_reclen;  /* advance */
  1931. X  return e->d_name;                             /* return name */
  1932. X#else /* !DIRENT */
  1933. X  return (e = readdir(d)) == NULL ? (char *)NULL : e->d_name;
  1934. X#endif /* ?DIRENT */
  1935. X}
  1936. X
  1937. X
  1938. X#ifdef DIRENT
  1939. Xlocal void closed(d)
  1940. Xdstrm *d;               /* directory stream to close */
  1941. X/* Close the directory stream */
  1942. X{
  1943. X  close(d->f);
  1944. X  free((voidp *)d);
  1945. X}
  1946. X#else /* !DIRENT */
  1947. X#  define closed closedir
  1948. X#endif /* ?DIRENT */
  1949. X
  1950. X
  1951. X#ifdef MSDOS
  1952. X
  1953. Xint wild(w)
  1954. Xchar *w;                /* path/pattern to match */
  1955. X/* If not in exclude mode, expand the pattern based on the contents of the
  1956. X   file system.  Return an error code in the ZE_ class. */
  1957. X{
  1958. X  char *a;              /* alloc'ed space for name */
  1959. X  dstrm *d;             /* stream for reading directory */
  1960. X  char *e;              /* name found in directory */
  1961. X  int f;                /* true if there was a match */
  1962. X  char *n;              /* constructed name from directory */
  1963. X  char *p;              /* path */
  1964. X  char *q;              /* name */
  1965. X  int r;                /* temporary variable */
  1966. X  char v[5];            /* space for device current directory */
  1967. X
  1968. X  /* Allocate and copy pattern */
  1969. X  if ((p = a = malloc(strlen(w) + 1)) == NULL)
  1970. X    return ZE_MEM;
  1971. X  strcpy(p, w);
  1972. X
  1973. X  /* Normalize pattern to upper case, path delimiter as '/'. */
  1974. X#if defined(FORCE_UPPER)
  1975. X#ifndef OS2
  1976. X  strupr(p);                            /* convert to upper case */
  1977. X#else /* OS2 */
  1978. X  if (IsFileSystemFAT(p)) strupr(p);
  1979. X#endif /* !OS2 */
  1980. X#endif
  1981. X  for (q = p; *q; q++)                  /* use / consistently */
  1982. X    if (*q == '\\')
  1983. X      *q = '/';
  1984. X
  1985. X  /* If excluding, don't bother with file system */
  1986. X  if (exflag)
  1987. X  {
  1988. X    r = procname(p);
  1989. X    free((voidp *)a);
  1990. X    return r;
  1991. X  }
  1992. X
  1993. X  /* Only name can have special matching characters */
  1994. X  if ((q = isshexp(p)) != NULL &&
  1995. X      (strrchr(q, '/') != NULL || strrchr(q, ':') != NULL))
  1996. X  {
  1997. X    free((voidp *)a);
  1998. X    return ZE_PARMS;
  1999. X  }
  2000. X
  2001. X  /* Separate path and name into p and q */
  2002. X  if ((q = strrchr(p, '/')) != NULL && (q == p || q[-1] != ':'))
  2003. X  {
  2004. X    *q++ = 0;                           /* path/name -> path, name */
  2005. X    if (*p == 0)                        /* path is just / */
  2006. X      p = strcpy(v, "/.");
  2007. X  }
  2008. X  else if ((q = strrchr(p, ':')) != NULL)
  2009. X  {                                     /* has device and no or root path */
  2010. X    *q++ = 0;
  2011. X    p = strcat(strcpy(v, p), ":");      /* copy device as path */
  2012. X    if (*q == '/')                      /* -> device:/., name */
  2013. X    {
  2014. X      strcat(p, "/");
  2015. X      q++;
  2016. X    }
  2017. X    strcat(p, ".");
  2018. X  }
  2019. X  else                                  /* no path or device */
  2020. X  {
  2021. X    q = p;
  2022. X    p = strcpy(v, ".");
  2023. X  }
  2024. X
  2025. X  /* Search that level for matching names */
  2026. X  if ((d = opend(p)) == NULL)
  2027. X  {
  2028. X    free((voidp *)a);
  2029. X    return ZE_MISS;
  2030. X  }
  2031. X  if ((r = strlen(p)) > 1 &&
  2032. X      (strcmp(p + r - 2, ":.") == 0 || strcmp(p + r - 2, "/.") == 0))
  2033. X    *(p + r - 1) = 0;
  2034. X  f = 0;
  2035. X  while ((e = readd(d)) != NULL)
  2036. X    if (strcmp(e, ".") && strcmp(e, "..") && MATCH(q, e))
  2037. X    {
  2038. X      f = 1;
  2039. X      if (strcmp(p, ".") == 0)                  /* path is . */
  2040. X        procname(e);                            /* name is name */
  2041. X      else
  2042. X      {
  2043. X        if ((n = malloc(strlen(p) + strlen(e) + 2)) == NULL)
  2044. X        {
  2045. X          free((voidp *)a);
  2046. X          return ZE_MEM;
  2047. X        }
  2048. X        n = strcpy(n, p);
  2049. X        if (n[r = strlen(n) - 1] != '/' && n[r] != ':')
  2050. X          strcat(n, "/");
  2051. X        r = procname(strcat(n, e));             /* name is path/name */
  2052. X        free((voidp *)n);
  2053. X        if (r)
  2054. X        {
  2055. X          free((voidp *)a);
  2056. X          return r;
  2057. X        }
  2058. X      }
  2059. X    }
  2060. X  closed(d);
  2061. X
  2062. X  /* Done */
  2063. X  free((voidp *)a);
  2064. X  return f ? ZE_OK : ZE_MISS;
  2065. X}
  2066. X
  2067. X#endif /* MSDOS */
  2068. X
  2069. X
  2070. X#ifdef VMS
  2071. Xint wild(p)
  2072. Xchar *p;                /* path/pattern to match */
  2073. X/* Expand the pattern based on the contents of the file system.  Return an
  2074. X   error code in the ZE_ class. */
  2075. X{
  2076. X  dstrm *d;             /* stream for reading directory */
  2077. X  char *e;              /* name found in directory */
  2078. X  int f;                /* true if there was a match */
  2079. X
  2080. X  /* Search given pattern for matching names */
  2081. X  if ((d = (dstrm *)malloc(sizeof(dstrm))) == NULL)
  2082. X    return ZE_MEM;
  2083. X  vms_wild(p, d);       /* pattern may be more than just directory name */
  2084. X  f = 0;
  2085. X  while ((e = readd(d)) != NULL)        /* "dosmatch" is already built in */
  2086. X    if (procname(e) == ZE_OK)
  2087. X      f = 1;
  2088. X  closed(d);
  2089. X
  2090. X  /* Done */
  2091. X  return f ? ZE_OK : ZE_MISS;
  2092. X}
  2093. X#endif /* VMS */
  2094. X
  2095. X
  2096. Xchar *getnam(n)
  2097. Xchar *n;                /* where to put name (must have >=FNMAX+1 bytes) */
  2098. X/* Read a space, \n, \r, or \t delimited name from stdin into n, and return
  2099. X   n.  If EOF, then return NULL.  Also, if the name read is too big, return
  2100. X   NULL. */
  2101. X{
  2102. X  int c;                /* last character read */
  2103. X  char *p;              /* pointer into name area */
  2104. X
  2105. X  p = n;
  2106. X  while ((c = getchar()) == ' ' || c == '\n' || c == '\r' || c == '\t')
  2107. X    ;
  2108. X  if (c == EOF)
  2109. X    return NULL;
  2110. X  do {
  2111. X    if (p - n >= FNMAX)
  2112. X      return NULL;
  2113. X    *p++ = (char)c;
  2114. X    c = getchar();
  2115. X  } while (c != EOF && c != ' ' && c != '\n' && c != '\r' && c != '\t');
  2116. X  *p = 0;
  2117. X  return n;
  2118. X}
  2119. X
  2120. X
  2121. Xstruct flist far *fexpel(f)
  2122. Xstruct flist far *f;    /* entry to delete */
  2123. X/* Delete the entry *f in the doubly-linked found list.  Return pointer to
  2124. X   next entry to allow stepping through list. */
  2125. X{
  2126. X  struct flist far *t;  /* temporary variable */
  2127. X
  2128. X  t = f->nxt;
  2129. X  *(f->lst) = t;                        /* point last to next, */
  2130. X  if (t != NULL)
  2131. X    t->lst = f->lst;                    /* and next to last */
  2132. X  if (f->name != NULL)                  /* free memory used */
  2133. X    free((voidp *)(f->name));
  2134. X  if (f->zname != NULL)
  2135. X    free((voidp *)(f->zname));
  2136. X  farfree((voidp far *)f);
  2137. X  fcount--;                             /* decrement count */
  2138. X  return t;                             /* return pointer to next */
  2139. X}
  2140. X
  2141. X
  2142. Xlocal int fqcmp(a, b)
  2143. Xvoidp *a, *b;           /* pointers to pointers to found entries */
  2144. X/* Used by qsort() to compare entries in the found list by name. */
  2145. X{
  2146. X  return strcmp((*(struct flist far **)a)->name,
  2147. X                (*(struct flist far **)b)->name);
  2148. X}
  2149. X
  2150. X
  2151. Xlocal int fqcmpz(a, b)
  2152. Xvoidp *a, *b;           /* pointers to pointers to found entries */
  2153. X/* Used by qsort() to compare entries in the found list by zname. */
  2154. X{
  2155. X  return strcmp((*(struct flist far **)a)->zname,
  2156. X                (*(struct flist far **)b)->zname);
  2157. X}
  2158. X
  2159. X
  2160. Xlocal char *last(p)
  2161. Xchar *p;                /* sequence of / delimited path components */
  2162. X/* Return a pointer to the start of the last path component. */
  2163. X{
  2164. X  char *t;              /* temporary variable */
  2165. X
  2166. X#ifdef VMS
  2167. X  if ((t = strrchr(p, ']')) != NULL)
  2168. X#else /* !VMS */
  2169. X  if ((t = strrchr(p, '/')) != NULL)
  2170. X#endif /* ?VMS */
  2171. X    return t + 1;
  2172. X  else
  2173. X    return p;
  2174. X}
  2175. X
  2176. X
  2177. Xlocal char *msname(n)
  2178. Xchar *n;
  2179. X/* Reduce all path components to MSDOS upper case 8.3 style names.  Probably
  2180. X   should also check for invalid characters, but I don't know which ones
  2181. X   those are. */
  2182. X{
  2183. X  int c;                /* current character */
  2184. X  int f;                /* characters in current component */
  2185. X  char *p;              /* source pointer */
  2186. X  char *q;              /* destination pointer */
  2187. X
  2188. X  p = q = n;
  2189. X  f = 0;
  2190. X  while ((c = *p++) != 0)
  2191. X    if (c == '/')
  2192. X    {
  2193. X      *q++ = (char)c;
  2194. X      f = 0;                            /* new component */
  2195. X    }
  2196. X    else if (c == '.')
  2197. X      if (f < 9)
  2198. X      {
  2199. X        *q++ = (char)c;
  2200. X        f = 9;                          /* now in file type */
  2201. X      }
  2202. X      else
  2203. X        f = 12;                         /* now just excess characters */
  2204. X    else
  2205. X      if (f < 12 && f != 8)
  2206. X      {
  2207. X        *q++ = (char)(to_up(c));
  2208. X        f++;                            /* do until end of name or type */
  2209. X      }
  2210. X  *q = 0;
  2211. X  return n;
  2212. X}
  2213. X
  2214. X
  2215. X#ifdef VMS
  2216. Xlocal char *strlower(s)
  2217. Xchar *s;                /* string to convert */
  2218. X/* Convert all uppercase letters to lowercase in string s */
  2219. X{
  2220. X  char *p;              /* scans string */
  2221. X
  2222. X  for (p = s; *p; p++)
  2223. X    if (*p >= 'A' && *p <= 'Z')
  2224. X      *p += 'a' - 'A';
  2225. X  return s;
  2226. X}
  2227. X
  2228. Xlocal char *strupper(s)
  2229. Xchar *s;                /* string to convert */
  2230. X/* Convert all lowercase letters to uppercase in string s */
  2231. X{
  2232. X  char *p;              /* scans string */
  2233. X
  2234. X  for (p = s; *p; p++)
  2235. X    if (*p >= 'a' && *p <= 'z')
  2236. X      *p -= 'a' - 'A';
  2237. X  return s;
  2238. X}
  2239. X#endif /* VMS */
  2240. X
  2241. Xlocal char *ex2in(x, pdosflag)
  2242. Xchar *x;                /* external file name */
  2243. Xint *pdosflag;          /* output: force MSDOS file attributes? */
  2244. X/* Convert the external file name to a zip file name, returning the malloc'ed
  2245. X   string or NULL if not enough memory. */
  2246. X{
  2247. X  char *n;              /* internal file name (malloc'ed) */
  2248. X  char *t;              /* shortened name */
  2249. X  int dosflag;
  2250. X
  2251. X#ifdef OS2
  2252. X  dosflag = dosify || IsFileSystemFAT(x);
  2253. X  if ( !dosify && use_longname_ea && (t = GetLongPathEA(x)) != NULL )
  2254. X  {
  2255. X    x = t;
  2256. X    dosflag = 0;
  2257. X  }
  2258. X#else
  2259. X# ifdef MSDOS
  2260. X  dosflag = 1;
  2261. X# else /* !MSDOS */
  2262. X  dosflag = dosify; /* default for non-DOS and non-OS/2 */
  2263. X# endif /* MSDOS */
  2264. X#endif /* OS2 */
  2265. X
  2266. X  /* Find starting point in name before doing malloc */
  2267. X#ifdef MSDOS                            /* msdos */
  2268. X  t = *x && *(x + 1) == ':' ? x + 2 : x;
  2269. X  while (*t == '/' || *t == '\\')
  2270. X    t++;
  2271. X#else /* !MSDOS */
  2272. X#  ifdef VMS                            /* vms */
  2273. X  t = x;
  2274. X  if ((n = strrchr(t, ':')) != NULL)
  2275. X    t = n + 1;
  2276. X  if (*t == '[' && (n = strrchr(t, ']')) != NULL)
  2277. X    if ((x = strchr(t, '.')) != NULL && x < n)
  2278. X      t = x + 1;
  2279. X    else
  2280. X      t = n + 1;
  2281. X#  else /* !VMS */                      /* unix */
  2282. X  for (t = x; *t == '/'; t++)
  2283. X    ;
  2284. X#  endif /* ?VMS */
  2285. X#endif /* ?MSDOS */
  2286. X
  2287. X  /* Make changes, if any, to the copied name (leave original intact) */
  2288. X#ifdef MSDOS
  2289. X  for (n = t; *n; n++)
  2290. X    if (*n == '\\')
  2291. X      *n = '/';
  2292. X#endif /* MSDOS */
  2293. X
  2294. X  if (!pathput)
  2295. X    t = last(t);
  2296. X
  2297. X  /* Malloc space for internal name and copy it */
  2298. X  if ((n = malloc(strlen(t) + 1)) == NULL)
  2299. X    return NULL;
  2300. X  strcpy(n, t);
  2301. X
  2302. X#ifdef VMS
  2303. X  if ((t = strrchr(n, ']')) != NULL)
  2304. X  {
  2305. X    *t = '/';
  2306. X    while (--t > n)
  2307. X      if (*t == '.')
  2308. X        *t = '/';
  2309. X  }
  2310. X
  2311. X  /* Fix from Greg Roelofs: */
  2312. X  /* Get current working directory and strip from n (t now = n) */
  2313. X  {
  2314. X    char cwd[256], *p, *q;
  2315. X    int c;
  2316. X
  2317. X    if (getcwd(cwd, 256) && ((p = strchr(cwd, '.')) != NULL))
  2318. X    {
  2319. X      ++p;
  2320. X      if ((q = strrchr(p, ']')) != NULL)
  2321. X      {
  2322. X        *q = '/';
  2323. X        while (--q > p)
  2324. X          if (*q == '.')
  2325. X            *q = '/';
  2326. X        /* strip bogus path parts from n */
  2327. X        if (strncmp(n, p, (c=strlen(p))) == 0)
  2328. X        {
  2329. X          q = n + c;
  2330. X          while (*t++ = *q++)
  2331. X            ;
  2332. X        }
  2333. X      }
  2334. X    }
  2335. X  }
  2336. X  strlower(n);
  2337. X  if (!vmsver)
  2338. X    if ((t = strrchr(n, ';')) != NULL)
  2339. X      *t = 0;
  2340. X
  2341. X  if( (t = strrchr(n, '.')) != NULL )
  2342. X  {
  2343. X    if( t[1] == 0 )               /* "filename." -> "filename" */
  2344. X      *t = 0;
  2345. X    else if( t[1] == ';' )        /* "filename.;vvv" -> "filename;vvv" */
  2346. X    {
  2347. X      char *f;
  2348. X      for( f=t+1; *t++ = *f++; )
  2349. X        ;
  2350. X    }
  2351. X  }
  2352. X#endif /* VMS */
  2353. X  if (dosify)
  2354. X    msname(n);
  2355. X#if defined(MSDOS) && !defined(OS2) && !defined(FORCE_UPPER)
  2356. X  else
  2357. X    strlwr(n);
  2358. X#endif
  2359. X  /* Returned malloc'ed name */
  2360. X  if (pdosflag) 
  2361. X    *pdosflag = dosflag;
  2362. X  return n;
  2363. X}
  2364. X
  2365. X
  2366. Xchar *in2ex(n)
  2367. Xchar *n;                /* internal file name */
  2368. X/* Convert the zip file name to an external file name, returning the malloc'ed
  2369. X   string or NULL if not enough memory. */
  2370. X{
  2371. X  char *x;              /* external file name */
  2372. X#ifdef VMS
  2373. X  char *t;              /* scans name */
  2374. X
  2375. X  if ((t = strrchr(n, '/')) == NULL)
  2376. X#endif /* VMS */
  2377. X  {
  2378. X    if ((x = malloc(strlen(n) + 1 + PAD)) == NULL)
  2379. X      return NULL;
  2380. X    strcpy(x, n);
  2381. X  }
  2382. X#ifdef VMS
  2383. X  else
  2384. X  {
  2385. X    if ((x = malloc(strlen(n) + 3 + PAD)) == NULL)
  2386. X      return NULL;
  2387. X    strcpy(x, "[.");
  2388. X    strcpy(x + 2, n);
  2389. X    *(t = x + 2 + (t - n)) = ']';
  2390. X    while (--t > x)
  2391. X      if (*t == '/')
  2392. X        *t = '.';
  2393. X  }
  2394. X  strupper(x);
  2395. X#endif /* VMS */
  2396. X#ifdef OS2
  2397. X  if ( !IsFileNameValid(x) )
  2398. X    ChangeNameForFAT(x);
  2399. X#endif /* !OS2 */
  2400. X#if defined(FORCE_UPPER) && defined(MSDOS)
  2401. X  /* Don't convert to upper case, causes wrong warnings. Keep the
  2402. X   * name as it was before in the old zip file.
  2403. X   */
  2404. X  strupr(x);
  2405. X#endif
  2406. X  return x;
  2407. X}
  2408. X
  2409. X
  2410. Xint exclude()
  2411. X/* Change from including to excluding names when procname() called.  Return
  2412. X   an error code in the ZE_ class. */
  2413. X{
  2414. X  struct flist far *f;          /* steps through found linked list */
  2415. X  extent j;                     /* index for s */
  2416. X  struct flist far **s;         /* sorted table */
  2417. X
  2418. X  /* sort found list, remove duplicates */
  2419. X  if (fcount)
  2420. X  {
  2421. X    if ((s = (struct flist far **)malloc(
  2422. X         fcount * sizeof(struct flist far *))) == NULL)
  2423. X      return ZE_MEM;
  2424. X    for (j = 0, f = found; f != NULL; f = f->nxt)
  2425. X      s[j++] = f;
  2426. X    qsort((char *)s, fcount, sizeof(struct flist far *), fqcmp);
  2427. X    for (j = fcount - 1; j > 0; j--)
  2428. X      if (strcmp(s[j - 1]->name, s[j]->name) == 0)
  2429. X        fexpel(s[j]);           /* fexpel() changes fcount */
  2430. X    qsort((char *)s, fcount, sizeof(struct flist far *), fqcmpz);
  2431. X    for (j = 1; j < fcount; j++)
  2432. X      if (strcmp(s[j - 1]->zname, s[j]->zname) == 0)
  2433. X      {
  2434. X        warn("name in zip file repeated: ", s[j]->zname);
  2435. X        warn("  first full name: ", s[j - 1]->name);
  2436. X        warn(" second full name: ", s[j]->name);
  2437. X        return ZE_PARMS;
  2438. X      }
  2439. X    free((voidp *)s);
  2440. X  }
  2441. X  exflag = 1;
  2442. X  return ZE_OK;
  2443. X}
  2444. X
  2445. X
  2446. Xlocal int newname(n)
  2447. Xchar *n;                /* name to add (or exclude) */
  2448. X/* Add (or exclude) a name that is not in the zip file.  Return an error
  2449. X   code in the ZE_ class. */
  2450. X{
  2451. X  char *m;
  2452. X  struct flist far *f;  /* where in found, or new found entry */
  2453. X  struct zlist far *z;  /* where in zfiles (if found) */
  2454. X  int dosflag;
  2455. X
  2456. X  /* Search for name in zip file.  If there, mark it, else add to
  2457. X     list of new names to do (or remove from that list). */
  2458. X  if ((m = ex2in(n, &dosflag)) == NULL)
  2459. X    return ZE_MEM;
  2460. X  if ((z = zsearch(m)) != NULL)
  2461. X    if (exflag)
  2462. X    {
  2463. X      z->mark = 0;
  2464. X      free((voidp *)m);
  2465. X      if (verbose)
  2466. X        printf("zip diagnostic: excluding %s\n", z->name);
  2467. X    }
  2468. X    else
  2469. X    {
  2470. X      free((voidp *)(z->name));
  2471. X      free((voidp *)(z->zname));
  2472. X      if ((z->name = malloc(strlen(n) + 1 + PAD)) == NULL)
  2473. X        return ZE_MEM;
  2474. X      strcpy(z->name, n);
  2475. X      z->zname = m;
  2476. X      z->mark = 1;
  2477. X      z->dosflag = dosflag;
  2478. X      if (verbose)
  2479. X        printf("zip diagnostic: including %s\n", z->name);
  2480. X    }
  2481. X  else
  2482. X    if (exflag)
  2483. X    {
  2484. X      /* search list for name--if there, remove it */
  2485. X      for (f = found; f != NULL; f = f->nxt)
  2486. X        if (namecmp(n, f->name) == 0)
  2487. X        {
  2488. X          fexpel(f);
  2489. X          break;
  2490. X        }
  2491. X      free((voidp *)m);
  2492. X    }
  2493. X    else
  2494. X    {
  2495. X      /* allocate space and add to list */
  2496. X      if ((f = (struct flist far *)farmalloc(sizeof(struct flist))) == NULL ||
  2497. X          (f->name = malloc(strlen(n) + 1 + PAD)) == NULL)
  2498. X      {
  2499. X        if (f != NULL)
  2500. X          farfree((voidp far *)f);
  2501. X        return ZE_MEM;
  2502. X      }
  2503. X      strcpy(f->name, n);
  2504. X      f->zname = m;
  2505. X      f->dosflag = dosflag;
  2506. X      *fnxt = f;
  2507. X      f->lst = fnxt;
  2508. X      f->nxt = NULL;
  2509. X      fnxt = &f->nxt;
  2510. X      fcount++;
  2511. X    }
  2512. X  return ZE_OK;
  2513. X}
  2514. X
  2515. X
  2516. Xint procname(n)
  2517. Xchar *n;                /* name to process */
  2518. X/* Process a name or sh expression to operate on (or exclude).  Return
  2519. X   an error code in the ZE_ class. */
  2520. X{
  2521. X  char *a;              /* path and name for recursion */
  2522. X  dstrm *d;             /* directory stream from opend() */
  2523. X  char *e;              /* pointer to name from readd() */
  2524. X  struct flist far *f;  /* steps through found list */
  2525. X  int m;                /* matched flag */
  2526. X  char *p;              /* path for recursion */
  2527. X  struct stat s;        /* result of stat() */
  2528. X  struct zlist far *z;  /* steps through zfiles list */
  2529. X
  2530. X  if (strcmp(n, "-") == 0)   /* if compressing stdin */
  2531. X    return newname(n);
  2532. X  else if (
  2533. X#ifdef S_IFLNK          /* if symbolic links exist ... */
  2534. X      linkput ? lstat(n, &s) :
  2535. X#endif /* S_IFLNK */
  2536. X      SSTAT(n, &s)
  2537. X#if defined(__TURBOC__) || defined(VMS)
  2538. X       /* Borland and VMS C bug: stat() succeeds on wild card names! */
  2539. X      || isshexp(n)
  2540. X#endif
  2541. X     )
  2542. X  {
  2543. X    /* Not a file or directory--search for shell expression in zip file */
  2544. X    p = ex2in(n, NULL);         /* shouldn't affect matching chars */
  2545. X    m = 1;
  2546. X    for (z = zfiles; z != NULL; z = z->nxt)
  2547. X      if (MATCH(p, z->zname))
  2548. X      {
  2549. X        z->mark = !exflag;
  2550. X        if (verbose)
  2551. X          printf("zip diagnostic: %scluding %s\n",
  2552. X                 exflag ? "ex" : "in", z->name);
  2553. X        m = 0;
  2554. X      }
  2555. X    /* If excluding, also search for expression in found list */
  2556. X    if (exflag)
  2557. X    {
  2558. X      for (f = found; f != NULL;)
  2559. X        if (MATCH(p, f->zname))
  2560. X        {
  2561. X          f = fexpel(f);
  2562. X          m = 0;
  2563. X        }
  2564. X        else
  2565. X          f = f->nxt;
  2566. X    }
  2567. X    free((voidp *)p);
  2568. X    if (m)
  2569. X      return ZE_MISS;           /* no match */
  2570. X  }
  2571. X  else
  2572. X  {
  2573. X    /* Live name--use if file, recurse if directory */
  2574. X#if defined(FORCE_UPPER) && defined(MSDOS)
  2575. X# ifndef OS2
  2576. X    strupr(n);                  /* convert to upper case */
  2577. X# else /* OS2 */
  2578. X    if (IsFileSystemFAT(n)) strupr(n);
  2579. X# endif /* !OS2 */
  2580. X#endif
  2581. X
  2582. X#ifdef MSDOS
  2583. X    for (p = n; *p; p++)          /* use / consistently */
  2584. X      if (*p == '\\')
  2585. X        *p = '/';
  2586. X#endif /* MSDOS */
  2587. X    if ((s.st_mode & S_IFDIR) == 0)
  2588. X    {
  2589. X      /* add or remove name of file */
  2590. X        if ((m = newname(n)) != ZE_OK)
  2591. X          return m;
  2592. X    } else {
  2593. X        /* recurse into directory */
  2594. X        if (recurse && (d = opend(n)) != NULL)
  2595. X        {
  2596. X#ifdef VMS
  2597. X          while ((e = readd(d)) != NULL)
  2598. X            if ((m = procname(e)) != ZE_OK)     /* recurse on name */
  2599. X            {
  2600. X              /* want to just set warning error and continue */
  2601. X              closed(d);
  2602. X              return m;
  2603. X            }
  2604. X#else /* !VMS */
  2605. X          if ((p = malloc(strlen(n)+2)) == NULL)
  2606. X            return ZE_MEM;
  2607. X          if (strcmp(n, ".") == 0)
  2608. X            *p = 0; /* avoid "./" prefix and do not create zip entry */
  2609. X          else
  2610. X          {
  2611. X            strcpy(p, n);
  2612. X            a = p + strlen(p);
  2613. X            if (a[-1] != '/')
  2614. X              strcpy(a, "/");
  2615. X            if ((m = newname(p)) != ZE_OK)
  2616. X              return m;
  2617. X          }
  2618. X          while ((e = readd(d)) != NULL)
  2619. X            if (strcmp(e, ".") && strcmp(e, ".."))
  2620. X            {
  2621. X              if ((a = malloc(strlen(p) + strlen(e) + 1)) == NULL)
  2622. X              {
  2623. X                free((voidp *)p);
  2624. X                closed(d);
  2625. X                return ZE_MEM;
  2626. X              }
  2627. X              strcat(strcpy(a, p), e);
  2628. X              if ((m = procname(a)) != ZE_OK)   /* recurse on name */
  2629. X              {
  2630. X                free((voidp *)a);  free((voidp *)p);
  2631. X                closed(d);
  2632. X                return m;
  2633. X              }
  2634. X              free((voidp *)a);
  2635. X            }
  2636. X          free((voidp *)p);
  2637. X#endif /* ?VMS */
  2638. X          closed(d);
  2639. X        }
  2640. X      }
  2641. X    }
  2642. X  return ZE_OK;
  2643. X}
  2644. X
  2645. X
  2646. X#if !defined(CRAY) && !defined(__TURBOC__) && !defined(OS2) /* and ... */
  2647. X#if !defined( __GO32__)
  2648. X
  2649. Xlocal int cmptime(p, q)
  2650. Xstruct tm *p, *q;       /* times to compare */
  2651. X/* Return negative if time p is before time q, positive if after, and
  2652. X   zero if the same */
  2653. X{
  2654. X  int r;                /* temporary variable */
  2655. X
  2656. X  if (p == NULL)
  2657. X    return -1;
  2658. X  else if ((r = p->tm_year - q->tm_year) != 0)
  2659. X    return r;
  2660. X  else if ((r = p->tm_mon - q->tm_mon) != 0)
  2661. X    return r;
  2662. X  else if ((r = p->tm_mday - q->tm_mday) != 0)
  2663. X    return r;
  2664. X  else if ((r = p->tm_hour - q->tm_hour) != 0)
  2665. X    return r;
  2666. X  else if ((r = p->tm_min - q->tm_min) != 0)
  2667. X    return r;
  2668. X  else
  2669. X    return p->tm_sec - q->tm_sec;
  2670. X}
  2671. X
  2672. X
  2673. Xlocal time_t invlocal(t)
  2674. Xstruct tm *t;           /* time to convert */
  2675. X/* Find inverse of localtime() using bisection.  This routine assumes that
  2676. X   time_t is an integer type, either signed or unsigned.  The expectation
  2677. X   is that sometime before the year 2038, time_t will be made a 64-bit
  2678. X   integer, and this routine will still work. */
  2679. X{
  2680. X  time_t i;             /* midpoint of current root range */
  2681. X  time_t l;             /* lower end of root range */
  2682. X  time_t u;             /* upper end of root range */
  2683. X
  2684. X  /* Bracket the root [0,largest time_t].  Note: if time_t is a 32-bit signed
  2685. X     integer, then the upper bound is GMT 1/19/2038 03:14:07, after which all
  2686. X     the Unix systems in the world come to a grinding halt.  Either that, or
  2687. X     all those systems will suddenly find themselves transported to December
  2688. X     of 1901 ... */
  2689. X  l = 0;
  2690. X  u = 1;
  2691. X  while (u < (u << 1))
  2692. X    u = (u << 1) + 1;
  2693. X
  2694. X  /* Find the root */
  2695. X  while (u - l > 1)
  2696. X  {
  2697. X    i = l + ((u - l) >> 1);
  2698. X    if (cmptime(localtime(&i), t) <= 0)
  2699. X      l = i;
  2700. X    else
  2701. X      u = i;
  2702. X  }
  2703. X  return l;
  2704. X}
  2705. X#endif
  2706. X#endif
  2707. X
  2708. X
  2709. Xvoid stamp(f, d)
  2710. Xchar *f;                /* name of file to change */
  2711. Xulg d;                  /* dos-style time to change it to */
  2712. X/* Set last updated and accessed time of file f to the DOS time d. */
  2713. X{
  2714. X#if defined(MACOS)
  2715. X  warn("timestamp not implemented yet", "");
  2716. X#else
  2717. X#ifdef __TURBOC__
  2718. X  int h;                /* file handle */
  2719. X
  2720. X  if ((h = open(f, 0)) != -1)
  2721. X  {
  2722. X#ifdef ATARI_ST
  2723. X    d = ( d >> 16 ) | ( d << 16 );
  2724. X#endif
  2725. X    setftime(h, (struct ftime *)&d);
  2726. X    close(h);
  2727. X  }
  2728. X#else /* !__TURBOC__ */
  2729. X#ifdef VMS
  2730. X  int tm_sec, tm_min, tm_hour, tm_mday, tm_mon, tm_year;
  2731. X  char timbuf[24];
  2732. X  static char *month[] = {"JAN", "FEB", "MAR", "APR", "MAY", "JUN",
  2733. X                          "JUL", "AUG", "SEP", "OCT", "NOV", "DEC"};
  2734. X  struct VMStimbuf {
  2735. X      char *actime;           /* VMS revision date, ASCII format */
  2736. X      char *modtime;          /* VMS creation date, ASCII format */
  2737. X  } ascii_times = {timbuf, timbuf};
  2738. X
  2739. X  /* Convert DOS time to ASCII format for VMSmunch */
  2740. X  tm_sec = (int)(d << 1) & 0x3e;
  2741. X  tm_min = (int)(d >> 5) & 0x3f;
  2742. X  tm_hour = (int)(d >> 11) & 0x1f;
  2743. X  tm_mday = (int)(d >> 16) & 0x1f;
  2744. X  tm_mon = ((int)(d >> 21) & 0xf) - 1;
  2745. X  tm_year = ((int)(d >> 25) & 0x7f) + 1980;
  2746. X  sprintf(timbuf, "%02d-%3s-%04d %02d:%02d:%02d.00", tm_mday, month[tm_mon],
  2747. X    tm_year, tm_hour, tm_min, tm_sec);
  2748. X
  2749. X  /* Set updated and accessed times of f */
  2750. X  if (VMSmunch(f, SET_TIMES, &ascii_times) != RMS$_NMF)
  2751. X    warn("can't set zipfile time: ", f);
  2752. X
  2753. X#else /* !VMS */
  2754. X#ifdef OS2
  2755. X  SetFileTime(f, d);
  2756. X#else /* !OS2 */
  2757. X  struct tm t;          /* argument for mktime() or invlocal() */
  2758. X  time_t u[2];          /* argument for utime() */
  2759. X#ifndef __GO32__
  2760. X  extern time_t mktime OF((struct tm *));
  2761. X#endif
  2762. X
  2763. X  /* Convert DOS time to time_t format in u[0] and u[1] */
  2764. X  t.tm_sec = (int)(d << 1) & 0x3e;
  2765. X  t.tm_min = (int)(d >> 5) & 0x3f;
  2766. X  t.tm_hour = (int)(d >> 11) & 0x1f;
  2767. X  t.tm_mday = (int)(d >> 16) & 0x1f;
  2768. X  t.tm_mon = ((int)(d >> 21) & 0xf) - 1;
  2769. X  t.tm_year = ((int)(d >> 25) & 0x7f) + 80;
  2770. X#if defined(MSDOS) || defined(OS2) || defined(CRAY)
  2771. X  /* mktime() is more reliable than invlocal() because the time range is
  2772. X   * wider on MSDOS than on Unix; required for Cray because invlocal assumes
  2773. X   * 32-bit ints
  2774. X   */
  2775. X  u[0] = u[1] = mktime(&t);
  2776. X#else
  2777. X  u[0] = u[1] = invlocal(&t);
  2778. X#endif
  2779. X
  2780. X  /* Set updated and accessed times of f */
  2781. X  utime(f, u);
  2782. X#endif /* ?OS2 */
  2783. X#endif /* ?VMS */
  2784. X#endif /* ?__TURBOC__ */
  2785. X#endif /* ?MACOS */
  2786. X}
  2787. X
  2788. X
  2789. Xlocal void inctime(s)
  2790. Xstruct tm *s;           /* time to increment in place */
  2791. X/* Increment the time structure *s by one second, return the result in
  2792. X   place. */
  2793. X{
  2794. X  int y;                /* temporary variable */
  2795. X
  2796. X  /* days in each month, except for February */
  2797. X  static int days[] = {31,0,31,30,31,30,31,31,30,31,30,31};
  2798. X
  2799. X  /* Set days in February from year (1900 is a leap year, 2000 is not) */
  2800. X  y = s->tm_year + 1900;
  2801. X  days[1] = y % 4 == 0 && (y % 100 != 0 || y % 400 == 0) ? 29 : 28;
  2802. X
  2803. X  /* Increment time with carry */
  2804. X  if (s->tm_sec != 59)
  2805. X    s->tm_sec++;
  2806. X  else if (s->tm_sec = 0, s->tm_min != 59)
  2807. X    s->tm_min++;
  2808. X  else if (s->tm_min = 0, s->tm_hour != 23)
  2809. X    s->tm_hour++;
  2810. X  else if (s->tm_hour = 0, s->tm_mday != days[s->tm_mon])
  2811. X    s->tm_mday++;
  2812. X  else if (s->tm_mday = 1, s->tm_mon != 11)
  2813. X    s->tm_mon++;
  2814. X  else
  2815. X  {
  2816. X    s->tm_mon = 0;
  2817. X    s->tm_year++;
  2818. X  }
  2819. X}
  2820. X
  2821. X
  2822. Xulg dostime(y, n, d, h, m, s)
  2823. Xint y;                  /* year */
  2824. Xint n;                  /* month */
  2825. Xint d;                  /* day */
  2826. Xint h;                  /* hour */
  2827. Xint m;                  /* minute */
  2828. Xint s;                  /* second */
  2829. X/* Convert the date y/n/d and time h:m:s to a four byte DOS date and
  2830. X   time (date in high two bytes, time in low two bytes allowing magnitude
  2831. X   comparison). */
  2832. X{
  2833. X  return y < 1980 ? dostime(1980, 1, 1, 0, 0, 0) :
  2834. X        (((ulg)y - 1980) << 25) | ((ulg)n << 21) | ((ulg)d << 16) |
  2835. X        ((ulg)h << 11) | ((ulg)m << 5) | ((ulg)s >> 1);
  2836. X}
  2837. X
  2838. X
  2839. Xlocal ulg unix2dostime(t)
  2840. Xstatime *t;             /* unix time to convert */
  2841. X/* Return the Unix time t in DOS format, rounded up to the next two
  2842. X   second boundary. */
  2843. X{
  2844. X  struct tm *s;         /* result of localtime() */
  2845. X
  2846. X  s = localtime(t);             /* Use local time since MSDOS does */
  2847. X  inctime(s);                   /* Add one second to round up */
  2848. X  return dostime(s->tm_year + 1900, s->tm_mon + 1, s->tm_mday,
  2849. X                 s->tm_hour, s->tm_min, s->tm_sec);
  2850. X}
  2851. X
  2852. X
  2853. Xulg filetime(f, a, n)
  2854. Xchar *f;                /* name of file to get info on */
  2855. Xulg *a;                 /* return value: file attributes */
  2856. Xlong *n;                /* return value: file size */
  2857. X/* If file *f does not exist, return 0.  Else, return the file's last
  2858. X   modified date and time as an MSDOS date and time.  The date and
  2859. X   time is returned in a long with the date most significant to allow
  2860. X   unsigned integer comparison of absolute times.  Also, if a is not
  2861. X   a NULL pointer, store the file attributes there, with the high two
  2862. X   bytes being the Unix attributes, and the low byte being a mapping
  2863. X   of that to DOS attributes.  If n is not NULL, store the file size
  2864. X   there.
  2865. X   If f is "-", use standard input as the file. If f is a device, return
  2866. X   a file size of -1 */
  2867. X{
  2868. X  struct stat s;        /* results of stat() */
  2869. X  char name[FNMAX];
  2870. X  int len = strlen(f);
  2871. X
  2872. X  strcpy(name, f);
  2873. X  if (name[len - 1] == '/')
  2874. X    name[len - 1] = 0; 
  2875. X  /* not all systems allow stat'ing a file with / appended */
  2876. X
  2877. X  if (strcmp(f, "-") == 0) {
  2878. X    if (fstat(fileno(stdin), &s) != 0)
  2879. X      error("fstat(stdin)");
  2880. X  } else if ((
  2881. X#ifdef S_IFLNK
  2882. X             linkput ? lstat(name, &s) :
  2883. X#endif
  2884. X             SSTAT(name, &s)) != 0 /* || (s.st_mode & S_IFDIR) != 0 */ )
  2885. X             /* Accept about any file kind except directories */
  2886. X    return 0;
  2887. X
  2888. X  if (a != NULL)
  2889. X#ifdef OS2
  2890. X    *a = (s.st_mode << 16) | GetFileMode(name);
  2891. X#else
  2892. X    *a = (s.st_mode << 16) | !(s.st_mode & S_IWRITE);
  2893. X#endif
  2894. X  if (n != NULL)
  2895. X    *n = (s.st_mode & S_IFREG) == 0 ? -1L : s.st_size;
  2896. X
  2897. X#ifdef OS2
  2898. X  return GetFileTime(name);
  2899. X#else /* !OS2 */
  2900. X#  ifdef VMS
  2901. X     return unix2dostime(&s.st_ctime);   /* Use creation time in VMS */
  2902. X#  else /* !VMS */
  2903. X#    ifdef ATARI_ST
  2904. X       return s.st_mtime; /* Turbo C doesn't use UNIX times */
  2905. X#    else
  2906. X       return unix2dostime(&s.st_mtime);
  2907. X#    endif
  2908. X#  endif /* ?VMS */
  2909. X#endif /* ?OS2 */
  2910. X}
  2911. X
  2912. X
  2913. Xint issymlnk(a)
  2914. Xulg a;                  /* Attributes returned by filetime() */
  2915. X/* Return true if the attributes are those of a symbolic link */
  2916. X{
  2917. X#ifdef S_IFLNK
  2918. X  return ((a >> 16) & S_IFMT) == S_IFLNK;
  2919. X#else /* !S_IFLNK */
  2920. X  return (int)a & 0;    /* avoid warning on unused parameter */
  2921. X#endif /* ?S_IFLNK */
  2922. X}
  2923. X
  2924. X
  2925. Xint deletedir(d)
  2926. Xchar *d;                /* directory to delete */
  2927. X/* Delete the (empty) directory *d.  Return the result of rmdir(), delete(),
  2928. X   or system(). */
  2929. X{
  2930. X#ifdef MACOS
  2931. X  warn("deletedir not implemented yet", "");
  2932. X  return 127;
  2933. X#else
  2934. X#ifdef RMDIR
  2935. X  /* code from Greg Roelofs, who horked it from Mark Edwards (unzip) */
  2936. X  int r, len;
  2937. X  char *s;              /* malloc'd string for system command */
  2938. X
  2939. X  len = strlen(d);
  2940. X  if ((s = malloc(len + 34)) == NULL)
  2941. X    return 127;
  2942. X
  2943. X#ifdef VMS
  2944. X  {
  2945. X    char *c;            /* pointer into VMS path */
  2946. X    /* convert "DEV:[DIR.SUB1.SUB2]" form to "DEV:[DIR.SUB1]SUB2.DIR;0" */
  2947. X    strcat(strcpy(s, "set prot=(o:rwed) "), d);   /* d starts at s+18 */
  2948. X    if (*(c = s+17+len) != ']')
  2949. X    {
  2950. X      free(s);
  2951. X      return 127;
  2952. X    }
  2953. X    strcpy(c, ".DIR;0");        /* 0 translates to highest version */
  2954. X    while (--c > s+18  &&  *c != '.'  &&  *c != '[') ;
  2955. X    if (c == s+18)
  2956. X    {
  2957. X      free(s);
  2958. X      return 127;
  2959. X    }
  2960. X    if (*c == '.')
  2961. X      *c = ']';
  2962. X    else if (*--c == ']')  /* presumably of form "DEV:[DIR.SUB1.][SUB2]" */
  2963. X    {                      /* (possible to have "DEV:[DIR.SUB1.][][SUB2]"?) */
  2964. X      char *b = c + 2;
  2965. X      c[-1] = ']';
  2966. X      while (*c++ = *b++) ;
  2967. X    }
  2968. X    else        /* must have reached device name:  can't delete top level */
  2969. X    {
  2970. X      free(s);
  2971. X      return 127;
  2972. X    }
  2973. X  }
  2974. X  /* unprotect directory and delete it as a file.  May fail if exists 
  2975. X     normal file "foo.dir" on top of directory "foo.dir" */
  2976. X  system(s);
  2977. X  r = delete(s+18);
  2978. X#else /* !VMS */
  2979. X  sprintf(s, "IFS=\" \t\n\" /bin/rmdir %s 2>/dev/null", d);
  2980. X  r = system(s);
  2981. X#endif /* ?VMS */
  2982. X  free(s);
  2983. X  return r;
  2984. X#else /* !RMDIR */
  2985. X  return rmdir(d);
  2986. X#endif /* ?RMDIR */
  2987. X#endif /* ?MACOS */
  2988. X}
  2989. X
  2990. X
  2991. X#endif /* !UTIL */
  2992. X
  2993. Xint destroy(f)
  2994. Xchar *f;                /* file to delete */
  2995. X/* Delete the file *f, returning non-zero on failure. */
  2996. X{
  2997. X  return unlink(f);
  2998. X}
  2999. X
  3000. X
  3001. Xint replace(d, s)
  3002. Xchar *d, *s;            /* destination and source file names */
  3003. X/* Replace file *d by file *s, removing the old *s.  Return an error code
  3004. X   in the ZE_ class. */
  3005. X{
  3006. X  struct stat t;        /* results of stat() */
  3007. X
  3008. X  if (SSTAT(d, &t) == 0 && unlink(d))
  3009. X    return ZE_CREAT;                    /* Can't erase zip file--give up */
  3010. X  if (link(s, d))                       /* Just move s on top of d */
  3011. X#if !defined(VMS) && !defined(ATARI_ST)
  3012. X    /* For VMS & ATARI assume failure is EXDEV */
  3013. X    if (errno != EXDEV
  3014. X#  ifdef ENOTSAM
  3015. X       && errno != ENOTSAM /* Used at least on Turbo C */
  3016. X#  endif
  3017. X        ) return ZE_CREAT;
  3018. X    else
  3019. X#endif
  3020. X    {
  3021. X      FILE *f, *g;      /* source and destination files */
  3022. X      int r;            /* temporary variable */
  3023. X
  3024. X      if ((f = fopen(s, FOPR)) == NULL) {
  3025. X        fprintf(stderr," replace: can't open %s\n", s);
  3026. X        return ZE_TEMP;
  3027. X      }
  3028. X      if ((g = fopen(d, FOPW)) == NULL)
  3029. X      {
  3030. X        fclose(f);
  3031. X        return ZE_CREAT;
  3032. X      }
  3033. X      r = fcopy(f, g, (ulg)-1L);
  3034. X      fclose(f);
  3035. X      if (fclose(g) || r != ZE_OK)
  3036. X      {
  3037. X        unlink(d);
  3038. X        return r ? (r == ZE_TEMP ? ZE_WRITE : r) : ZE_WRITE;
  3039. X      }
  3040. X#ifdef VMS /* only delete if rename failed:  previous version may exist */
  3041. X      unlink(s);
  3042. X    }
  3043. X#else /* !VMS */
  3044. X    }
  3045. X  unlink(s);
  3046. X#endif /* !VMS */
  3047. X  return ZE_OK;
  3048. X}
  3049. X
  3050. X
  3051. Xint getfileattr(f)
  3052. Xchar *f;                /* file path */
  3053. X/* Return the file attributes for file f or 0 if failure */
  3054. X{
  3055. X  struct stat s;
  3056. X
  3057. X  return SSTAT(f, &s) == 0 ? s.st_mode : 0;
  3058. X}
  3059. X
  3060. X
  3061. Xint setfileattr(f, a)
  3062. Xchar *f;                /* file path */
  3063. Xint a;                  /* attributes returned by getfileattr() */
  3064. X/* Give the file f the attributes a, return non-zero on failure */
  3065. X{
  3066. X#if defined (VMS) || defined(MACOS)
  3067. X  return 0;
  3068. X#else /* !VMS */
  3069. X  return chmod(f, a);
  3070. X#endif /* ?VMS */
  3071. X}
  3072. X
  3073. X
  3074. X#ifdef NO_MKTEMP
  3075. X
  3076. Xchar *tempname(zip)
  3077. X  char *zip;              /* path name of zip file to generate temp name for */
  3078. X
  3079. X/* Return a temporary file name in its own malloc'ed space.
  3080. X * This function might accidentally destroy an existing file
  3081. X * with extension .$z$ . Use mktemp below if you have it on your system.
  3082. X */
  3083. X{
  3084. X  char *p;              /* temporary pointer */
  3085. X  char *t;              /* malloc'ed space for name */
  3086. X
  3087. X  if ((t = malloc(strlen(zip)+5)) == NULL)
  3088. X    return NULL;
  3089. X  strcpy(t, zip);
  3090. X  if ((p = strrchr(t, '.')) != NULL &&
  3091. X      (!strncmp(p, ".zip", 4) || !strncmp(p, ".ZIP", 4)))
  3092. X      /* strncmp to avoid problems with VMS ';' */
  3093. X    strcpy(p, ".$z$");
  3094. X  else
  3095. X    strcat(t, ".$z$");
  3096. X
  3097. X  return t;
  3098. X}
  3099. X#else /* !NO_MKTEMP */
  3100. X
  3101. Xchar *tempname(zip)
  3102. X  char *zip;              /* path name of zip file to generate temp name for */
  3103. X
  3104. X/* Return a temporary file name in its own malloc'ed space, using tempath. */
  3105. X{
  3106. X  char *t = zip;   /* malloc'ed space for name (use zip to avoid warning) */
  3107. X
  3108. X  if (tempath != NULL)
  3109. X  {
  3110. X    if ((t = malloc(strlen(tempath)+10)) == NULL)
  3111. X      return NULL;
  3112. X    strcpy(t, tempath);
  3113. X#ifndef VMS
  3114. X    if (t[strlen(t)-1] != '/')
  3115. X      strcat(t, "/");
  3116. X#endif
  3117. X  }
  3118. X  else
  3119. X  {
  3120. X    if ((t = malloc(9)) == NULL)
  3121. X      return NULL;
  3122. X    *t = 0;
  3123. X  }
  3124. X  strcat(t, "_ZXXXXXX");
  3125. X  return mktemp(t);
  3126. X}
  3127. X
  3128. X#endif /* NO_MKTEMP */
  3129. X
  3130. X
  3131. Xint fcopy(f, g, n)
  3132. XFILE *f, *g;            /* source and destination files */
  3133. Xulg n;                  /* number of bytes to copy or -1 for all */
  3134. X/* Copy n bytes from file *f to file *g, or until EOF if n == -1.  Return
  3135. X   an error code in the ZE_ class. */
  3136. X{
  3137. X  char *b;              /* malloc'ed buffer for copying */
  3138. X  extent k;             /* result of fread() */
  3139. X  ulg m;                /* bytes copied so far */
  3140. X
  3141. X  if ((b = malloc(CBSZ)) == NULL)
  3142. X    return ZE_MEM;
  3143. X  m = 0;
  3144. X  while (n == -1L || m < n)
  3145. X  {
  3146. X    if ((k = fread(b, 1, n == -1 ?
  3147. X                   CBSZ : (n - m < CBSZ ? (extent)(n - m) : CBSZ), f)) == 0)
  3148. X      if (ferror(f))
  3149. X      {
  3150. X        free((voidp *)b);
  3151. X        return ZE_READ;
  3152. X      }
  3153. X      else
  3154. X        break;
  3155. X    if (fwrite(b, 1, k, g) != k)
  3156. X    {
  3157. X      free((voidp *)b);
  3158. X      fprintf(stderr," fcopy: write error\n");
  3159. X      return ZE_TEMP;
  3160. X    }
  3161. X    m += k;
  3162. X  }
  3163. X  free((voidp *)b);
  3164. X  return ZE_OK;
  3165. X}
  3166. X
  3167. X
  3168. X#ifdef CRYPT
  3169. X
  3170. X#ifndef MSDOS
  3171. X
  3172. X#ifdef VMS
  3173. X
  3174. Xint echo(opt)
  3175. X    int opt;
  3176. X{
  3177. X/*---------------------------------------------------------------------------
  3178. X    Based on VMSmunch.c, which in turn was based on Joe Meadows' file.c code.
  3179. X  ---------------------------------------------------------------------------
  3180. X     * For VMS v5.x:
  3181. X     *   IO$_SENSEMODE/SETMODE info:  Programming, Vol. 7A, System Programming,
  3182. X     *     I/O User's: Part I, sec. 8.4.1.1, 8.4.3, 8.4.5, 8.6
  3183. X     *   sys$assign(), sys$qio() info:  Programming, Vol. 4B, System Services,
  3184. X     *     System Services Reference Manual, pp. sys-23, sys-379
  3185. X     *   fixed-length descriptor info:  Programming, Vol. 3, System Services,
  3186. X     *     Intro to System Routines, sec. 2.9.2
  3187. X     * GRR, 15 Aug 91
  3188. X  ---------------------------------------------------------------------------*/
  3189. X    static struct dsc$descriptor_s DevDesc =
  3190. X        {9, DSC$K_DTYPE_T, DSC$K_CLASS_S, "SYS$INPUT"};
  3191. X     /* {dsc$w_length, dsc$b_dtype, dsc$b_class, dsc$a_pointer}; */
  3192. X    static short           DevChan, iosb[4];
  3193. X    static long            i, status;
  3194. X    static unsigned long   oldmode[2], newmode[2];   /* each = 8 bytes */
  3195. X  
  3196. X
  3197. X/*---------------------------------------------------------------------------
  3198. X    Assign a channel to standard input.
  3199. X  ---------------------------------------------------------------------------*/
  3200. X
  3201. X    status = sys$assign(&DevDesc, &DevChan, 0, 0);
  3202. X    if (!(status & 1))
  3203. X        return status;
  3204. X
  3205. X/*---------------------------------------------------------------------------
  3206. X    Use sys$qio and the IO$_SENSEMODE function to determine the current tty
  3207. X    status (for password reading, could use IO$_READVBLK function instead,
  3208. X    but echo on/off will be more general).
  3209. X  ---------------------------------------------------------------------------*/
  3210. X
  3211. X    status = sys$qio(0, DevChan, IO$_SENSEMODE, &iosb, 0, 0,
  3212. X                     oldmode, 8, 0, 0, 0, 0);
  3213. X    if (!(status & 1))
  3214. X        return status;
  3215. X    status = iosb[0];
  3216. X    if (!(status & 1))
  3217. X        return status;
  3218. X
  3219. X/*---------------------------------------------------------------------------
  3220. X    Copy old mode into new-mode buffer, then modify to be either NOECHO or
  3221. X    ECHO (depending on function argument opt).
  3222. X  ---------------------------------------------------------------------------*/
  3223. X
  3224. X    newmode[0] = oldmode[0];
  3225. X    newmode[1] = oldmode[1];
  3226. X    if (opt == 0)
  3227. X        newmode[1] |= TT$M_NOECHO;                      /* set NOECHO bit */
  3228. X    else
  3229. X        newmode[1] &= ~((unsigned long) TT$M_NOECHO);   /* clear NOECHO bit */
  3230. X
  3231. X/*---------------------------------------------------------------------------
  3232. X    Use the IO$_SETMODE function to change the tty status.
  3233. X  ---------------------------------------------------------------------------*/
  3234. X
  3235. X    status = sys$qio(0, DevChan, IO$_SETMODE, &iosb, 0, 0,
  3236. X                     newmode, 8, 0, 0, 0, 0);
  3237. X    if (!(status & 1))
  3238. X        return status;
  3239. X    status = iosb[0];
  3240. X    if (!(status & 1))
  3241. X        return status;
  3242. X
  3243. X/*---------------------------------------------------------------------------
  3244. X    Deassign the sys$input channel by way of clean-up, then exit happily.
  3245. X  ---------------------------------------------------------------------------*/
  3246. X
  3247. X    status = sys$dassgn(DevChan);
  3248. X    if (!(status & 1))
  3249. X        return status;
  3250. X
  3251. X    return SS$_NORMAL;   /* we be happy */
  3252. X
  3253. X} /* end function echo() */
  3254. X
  3255. X
  3256. X#else /* !VMS */
  3257. X
  3258. Xlocal int echofd = -1;  /* file descriptor whose echo is off */
  3259. X
  3260. Xvoid echoff(f)
  3261. Xint f;                  /* file descriptor to turn echo off on */
  3262. X/* Turn echo off for file descriptor f.  Assumes that f is a tty device. */
  3263. X{
  3264. X  struct sgttyb sg;     /* tty device structure */
  3265. X
  3266. X  echofd = f;
  3267. X  GTTY(f, &sg);                                 /* get settings */
  3268. X  sg.sg_flags &= ~ECHO;                         /* turn echo off */
  3269. X  STTY(f, &sg);
  3270. X}
  3271. X
  3272. Xvoid echon()
  3273. X/* Turn echo back on for file descriptor echofd. */
  3274. X{
  3275. X  struct sgttyb sg;     /* tty device structure */
  3276. X
  3277. X  if (echofd != -1)
  3278. X  {
  3279. X    GTTY(echofd, &sg);                          /* get settings */
  3280. X    sg.sg_flags |= ECHO;                        /* turn echo on */
  3281. X    STTY(echofd, &sg);
  3282. X    echofd = -1;
  3283. X  }
  3284. X}
  3285. X
  3286. X#endif /* ?VMS */
  3287. X
  3288. X#endif /* !MSDOS */
  3289. X
  3290. X
  3291. Xchar *getp(m, p, n)
  3292. Xchar *m;                /* prompt for password */
  3293. Xchar *p;                /* return value: line input */
  3294. Xint n;                  /* bytes available in p[] */
  3295. X/* Get a password of length n-1 or less into *p using the prompt *m.
  3296. X   The entered password is not echoed.  Return p on success, NULL on
  3297. X   failure (can't get controlling tty). */
  3298. X{
  3299. X  char c;               /* one-byte buffer for read() to use */
  3300. X  int i;                /* number of characters input */
  3301. X  char *w;              /* warning on retry */
  3302. X
  3303. X#ifndef MSDOS
  3304. X#ifndef VMS
  3305. X  int f;                /* file decsriptor for tty device */
  3306. X
  3307. X  /* Turn off echo on tty */
  3308. X  if (!isatty(2))
  3309. X    return NULL;                                /* error if not tty */
  3310. X  if ((f = open(ttyname(2), 0, 0)) == -1)
  3311. X    return NULL;
  3312. X#endif /* !VMS */
  3313. X  echoff(f);                                    /* turn echo off */
  3314. X#endif /* !MSDOS */
  3315. X
  3316. X  /* Get password */
  3317. X  w = "";
  3318. X  do {
  3319. X#ifdef VMS   /* bug:  VMS adds '\n' to NULL fputs (apparently) */
  3320. X    if (*w)
  3321. X#endif /* VMS */
  3322. X    fputs(w, stderr);                           /* warning if back again */
  3323. X    fputs(m, stderr);                           /* prompt */
  3324. X    fflush(stderr);
  3325. X    i = 0;
  3326. X    do {                                        /* read line, keeping n */
  3327. X#ifdef MSVMS
  3328. X      if ((c = (char)getch()) == '\r')
  3329. X        c = '\n';
  3330. X#else /* !MSVMS */
  3331. X      read(f, &c, 1);
  3332. X#endif /* ?MSVMS */
  3333. X      if (i < n)
  3334. X        p[i++] = c;
  3335. X    } while (c != '\n');
  3336. X    putc('\n', stderr);  fflush(stderr);
  3337. X    w = "(line too long--try again)\n";
  3338. X  } while (p[i-1] != '\n');
  3339. X  p[i-1] = 0;                                   /* terminate at newline */
  3340. X
  3341. X#ifndef MSDOS
  3342. X  echon();                                      /* turn echo back on */
  3343. X#ifndef VMS
  3344. X  close(f);
  3345. X#endif /* !VMS */
  3346. X#endif /* !MSDOS */
  3347. X
  3348. X  /* Return pointer to password */
  3349. X  return p;
  3350. X}
  3351. X
  3352. X#endif /* ?CRYPT */
  3353. X
  3354. X
  3355. X#ifdef ZMEM
  3356. X
  3357. X/************************/
  3358. X/*  Function memset()  */
  3359. X/************************/
  3360. X
  3361. X/*
  3362. X * memset - for systems without it
  3363. X *  bill davidsen - March 1990
  3364. X */
  3365. X
  3366. Xchar *
  3367. Xmemset(buf, init, len)
  3368. Xregister char *buf;     /* buffer loc */
  3369. Xregister int init;      /* initializer */
  3370. Xregister unsigned int len;   /* length of the buffer */
  3371. X{
  3372. X    char *start;
  3373. X
  3374. X    start = buf;
  3375. X    while (len--) *(buf++) = init;
  3376. X    return(start);
  3377. X}
  3378. X
  3379. X
  3380. X/************************/
  3381. X/*  Function memcpy()  */
  3382. X/************************/
  3383. X
  3384. Xchar *
  3385. Xmemcpy(dst,src,len)           /* v2.0f */
  3386. Xregister char *dst, *src;
  3387. Xregister unsigned int len;
  3388. X{
  3389. X    char *start;
  3390. X
  3391. X    start = dst;
  3392. X    while (len--)
  3393. X        *dst++ = *src++;
  3394. X    return(start);
  3395. X}
  3396. X
  3397. X
  3398. X/************************/
  3399. X/*  Function memcmp()  */
  3400. X/************************/
  3401. X
  3402. Xint
  3403. Xmemcmp(b1,b2,len)                     /* jpd@usl.edu -- 11/16/90 */
  3404. Xregister char *b1, *b2;
  3405. Xregister unsigned int len;
  3406. X{
  3407. X
  3408. X    if (len) do {             /* examine each byte (if any) */
  3409. X      if (*b1++ != *b2++)
  3410. X        return (*((uch *)b1-1) - *((uch *)b2-1));  /* exit when miscompare */
  3411. X       } while (--len);
  3412. X
  3413. X    return(0);        /* no miscompares, yield 0 result */
  3414. X}
  3415. X
  3416. X#endif  /* ZMEM */
  3417. X
  3418. X#ifdef __TURBOC__
  3419. X
  3420. X/************************/
  3421. X/*  Function fcalloc()  */
  3422. X/************************/
  3423. X
  3424. X/* Turbo C malloc() does not allow dynamic allocation of 64K bytes
  3425. X * and farmalloc(64K) returns a pointer with an offset of 8, so we
  3426. X * must fix the pointer. Warning: the pointer must be put back to its
  3427. X * original form in order to free it.
  3428. X * For MSC, use halloc instead of this function (see tailor.h).
  3429. X */
  3430. Xvoid far * fcalloc(items, size)
  3431. X    unsigned items; /* number of items */
  3432. X    unsigned size;  /* item size */
  3433. X{
  3434. X    void far * buf = farmalloc((ulg)items*size + 16L);
  3435. X    /* Normalize the pointer to seg:0 */
  3436. X    *((int*)&buf+1) += ((unsigned)((uch*)buf-0) + 15) >> 4;
  3437. X    *(int*)&buf = 0;
  3438. X    return buf; /* buf stays NULL if alloc failed */
  3439. X}
  3440. X
  3441. X#endif /* __TURBOC__ */
  3442. END_OF_FILE
  3443.   if test 57097 -ne `wc -c <'fileio.c'`; then
  3444.     echo shar: \"'fileio.c'\" unpacked with wrong size!
  3445.   fi
  3446.   # end of 'fileio.c'
  3447. fi
  3448. echo shar: End of archive 2 \(of 11\).
  3449. cp /dev/null ark2isdone
  3450. MISSING=""
  3451. for I in 1 2 3 4 5 6 7 8 9 10 11 ; do
  3452.     if test ! -f ark${I}isdone ; then
  3453.     MISSING="${MISSING} ${I}"
  3454.     fi
  3455. done
  3456. if test "${MISSING}" = "" ; then
  3457.     echo You have unpacked all 11 archives.
  3458.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  3459. else
  3460.     echo You still must unpack the following archives:
  3461.     echo "        " ${MISSING}
  3462. fi
  3463. exit 0
  3464. exit 0 # Just in case...
  3465. Newsgroups: comp.sources.misc
  3466. From: zip-bugs@cs.ucla.edu (Info-ZIP group)
  3467. Subject:  v31i095:  zip19 - Info-ZIP portable Zip, version 1.9, Part03/11
  3468. Message-ID: <1992Aug23.064551.29045@sparky.imd.sterling.com>
  3469. X-Md4-Signature: 5ca732e6f20f0ad06e2b983530c09eca
  3470. Date: Sun, 23 Aug 1992 06:45:51 GMT
  3471. Approved: kent@sparky.imd.sterling.com
  3472.  
  3473. Submitted-by: zip-bugs@cs.ucla.edu (Info-ZIP group)
  3474. Posting-number: Volume 31, Issue 95
  3475. Archive-name: zip19/part03
  3476. Supersedes: zip: Volume 23, Issue 88-96
  3477. Environment: UNIX, VMS, OS/2, MS-DOS, MACINTOSH, WIN-NT, LINUX, MINIX, XOS, !AMIGA, ATARI, symlink, SGI, DEC, Cray, Convex, Amdahl, Sun, PC
  3478.  
  3479. #! /bin/sh
  3480. # This is a shell archive.  Remove anything before this line, then feed it
  3481. # into a shell via "sh file" or similar.  To overwrite existing files,
  3482. # type "sh file -c".
  3483. # The tool that generated this appeared in the comp.sources.unix newsgroup;
  3484. # send mail to comp-sources-unix@uunet.uu.net if you want that tool.
  3485. # Contents:  trees.c util.c vms/makefile.vms
  3486. # Wrapped by kent@sparky on Sun Aug 23 01:00:43 1992
  3487. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  3488. echo If this archive is complete, you will see the following message:
  3489. echo '          "shar: End of archive 3 (of 11)."'
  3490. if test -f 'trees.c' -a "${1}" != "-c" ; then 
  3491.   echo shar: Will not clobber existing file \"'trees.c'\"
  3492. else
  3493.   echo shar: Extracting \"'trees.c'\" \(40777 characters\)
  3494.   sed "s/^X//" >'trees.c' <<'END_OF_FILE'
  3495. X/*
  3496. X
  3497. X Copyright (C) 1990-1992 Mark Adler, Richard B. Wales, Jean-loup Gailly,
  3498. X Kai Uwe Rommel and Igor Mandrichenko.
  3499. X Permission is granted to any individual or institution to use, copy, or
  3500. X redistribute this software so long as all of the original files are included
  3501. X unmodified, that it is not sold for profit, and that this copyright notice
  3502. X is retained.
  3503. X
  3504. X*/
  3505. X
  3506. X/*
  3507. X *  trees.c by Jean-loup Gailly
  3508. X *
  3509. X *  This is a new version of im_ctree.c originally written by Richard B. Wales
  3510. X *  for the defunct implosion method.
  3511. X *
  3512. X *  PURPOSE
  3513. X *
  3514. X *      Encode various sets of source values using variable-length
  3515. X *      binary code trees.
  3516. X *
  3517. X *  DISCUSSION
  3518. X *
  3519. X *      The PKZIP "deflation" process uses several Huffman trees. The more
  3520. X *      common source values are represented by shorter bit sequences.
  3521. X *
  3522. X *      Each code tree is stored in the ZIP file in a compressed form
  3523. X *      which is itself a Huffman encoding of the lengths of
  3524. X *      all the code strings (in ascending order by source values).
  3525. X *      The actual code strings are reconstructed from the lengths in
  3526. X *      the UNZIP process, as described in the "application note"
  3527. X *      (APPNOTE.TXT) distributed as part of PKWARE's PKZIP program.
  3528. X *
  3529. X *  REFERENCES
  3530. X *
  3531. X *      Lynch, Thomas J.
  3532. X *          Data Compression:  Techniques and Applications, pp. 53-55.
  3533. X *          Lifetime Learning Publications, 1985.  ISBN 0-534-03418-7.
  3534. X *
  3535. X *      Storer, James A.
  3536. X *          Data Compression:  Methods and Theory, pp. 49-50.
  3537. X *          Computer Science Press, 1988.  ISBN 0-7167-8156-5.
  3538. X *
  3539. X *      Sedgewick, R.
  3540. X *          Algorithms, p290.
  3541. X *          Addison-Wesley, 1983. ISBN 0-201-06672-6.
  3542. X *
  3543. X *  INTERFACE
  3544. X *
  3545. X *      void ct_init (ush *attr, int *method)
  3546. X *          Allocate the match buffer, initialize the various tables and save
  3547. X *          the location of the internal file attribute (ascii/binary) and
  3548. X *          method (DEFLATE/STORE)
  3549. X *
  3550. X *      void ct_tally (int dist, int lc);
  3551. X *          Save the match info and tally the frequency counts.
  3552. X *
  3553. X *      long flush_block (char *buf, ulg stored_len, int eof)
  3554. X *          Determine the best encoding for the current block: dynamic trees,
  3555. X *          static trees or store, and output the encoded block to the zip
  3556. X *          file. Returns the total compressed length for the file so far.
  3557. X *
  3558. X */
  3559. X
  3560. X#include <ctype.h>
  3561. X#include "zip.h"
  3562. X
  3563. X/* ===========================================================================
  3564. X * Constants
  3565. X */
  3566. X
  3567. X#define MAX_BITS 15
  3568. X/* All codes must not exceed MAX_BITS bits */
  3569. X
  3570. X#define MAX_BL_BITS 7
  3571. X/* Bit length codes must not exceed MAX_BL_BITS bits */
  3572. X
  3573. X#define LENGTH_CODES 29
  3574. X/* number of length codes, not counting the special END_BLOCK code */
  3575. X
  3576. X#define LITERALS  256
  3577. X/* number of literal bytes 0..255 */
  3578. X
  3579. X#define END_BLOCK 256
  3580. X/* end of block literal code */
  3581. X
  3582. X#define L_CODES (LITERALS+1+LENGTH_CODES)
  3583. X/* number of Literal or Length codes, including the END_BLOCK code */
  3584. X
  3585. X#define D_CODES   30
  3586. X/* number of distance codes */
  3587. X
  3588. X#define BL_CODES  19
  3589. X/* number of codes used to transfer the bit lengths */
  3590. X
  3591. X
  3592. Xlocal int near extra_lbits[LENGTH_CODES] /* extra bits for each length code */
  3593. X   = {0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0};
  3594. X
  3595. Xlocal int near extra_dbits[D_CODES] /* extra bits for each distance code */
  3596. X   = {0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13};
  3597. X
  3598. Xlocal int near extra_blbits[BL_CODES]/* extra bits for each bit length code */
  3599. X   = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7};
  3600. X
  3601. X#define STORED_BLOCK 0
  3602. X#define STATIC_TREES 1
  3603. X#define DYN_TREES    2
  3604. X/* The three kinds of block type */
  3605. X
  3606. X#ifndef LIT_BUFSIZE
  3607. X#  ifdef SMALL_MEM
  3608. X#    define LIT_BUFSIZE  0x2000
  3609. X#  else
  3610. X#  ifdef MEDIUM_MEM
  3611. X#    define LIT_BUFSIZE  0x4000
  3612. X#  else
  3613. X#    define LIT_BUFSIZE  0x8000
  3614. X#  endif
  3615. X#  endif
  3616. X#endif
  3617. X#define DIST_BUFSIZE  LIT_BUFSIZE
  3618. X/* Sizes of match buffers for literals/lengths and distances.  There are
  3619. X * 4 reasons for limiting LIT_BUFSIZE to 64K:
  3620. X *   - frequencies can be kept in 16 bit counters
  3621. X *   - if compression is not successful for the first block, all input data is
  3622. X *     still in the window so we can still emit a stored block even when input
  3623. X *     comes from standard input.  (This can also be done for all blocks if
  3624. X *     LIT_BUFSIZE is not greater than 32K.)
  3625. X *   - if compression is not successful for a file smaller than 64K, we can
  3626. X *     even emit a stored file instead of a stored block (saving 5 bytes).
  3627. X *   - creating new Huffman trees less frequently may not provide fast
  3628. X *     adaptation to changes in the input data statistics. (Take for
  3629. X *     example a binary file with poorly compressible code followed by
  3630. X *     a highly compressible string table.) Smaller buffer sizes give
  3631. X *     fast adaptation but have of course the overhead of transmitting trees
  3632. X *     more frequently.
  3633. X *   - I can't count above 4
  3634. X * The current code is general and allows DIST_BUFSIZE < LIT_BUFSIZE (to save
  3635. X * memory at the expense of compression). Some optimizations would be possible
  3636. X * if we rely on DIST_BUFSIZE == LIT_BUFSIZE.
  3637. X */
  3638. X
  3639. X#define REP_3_6      16
  3640. X/* repeat previous bit length 3-6 times (2 bits of repeat count) */
  3641. X
  3642. X#define REPZ_3_10    17
  3643. X/* repeat a zero length 3-10 times  (3 bits of repeat count) */
  3644. X
  3645. X#define REPZ_11_138  18
  3646. X/* repeat a zero length 11-138 times  (7 bits of repeat count) */
  3647. X
  3648. X/* ===========================================================================
  3649. X * Local data
  3650. X */
  3651. X
  3652. X/* Data structure describing a single value and its code string. */
  3653. Xtypedef struct ct_data {
  3654. X    union {
  3655. X        ush  freq;       /* frequency count */
  3656. X        ush  code;       /* bit string */
  3657. X    } fc;
  3658. X    union {
  3659. X        ush  dad;        /* father node in Huffman tree */
  3660. X        ush  len;        /* length of bit string */
  3661. X    } dl;
  3662. X} ct_data;
  3663. X
  3664. X#define Freq fc.freq
  3665. X#define Code fc.code
  3666. X#define Dad  dl.dad
  3667. X#define Len  dl.len
  3668. X
  3669. X#define HEAP_SIZE (2*L_CODES+1)
  3670. X/* maximum heap size */
  3671. X
  3672. Xlocal ct_data near dyn_ltree[HEAP_SIZE];   /* literal and length tree */
  3673. Xlocal ct_data near dyn_dtree[2*D_CODES+1]; /* distance tree */
  3674. X
  3675. Xlocal ct_data near static_ltree[L_CODES+2];
  3676. X/* The static literal tree. Since the bit lengths are imposed, there is no
  3677. X * need for the L_CODES extra codes used during heap construction. However
  3678. X * The codes 286 and 287 are needed to build a canonical tree (see ct_init
  3679. X * below).
  3680. X */
  3681. X
  3682. Xlocal ct_data near static_dtree[D_CODES];
  3683. X/* The static distance tree. (Actually a trivial tree since all codes use
  3684. X * 5 bits.)
  3685. X */
  3686. X
  3687. Xlocal ct_data near bl_tree[2*BL_CODES+1];
  3688. X/* Huffman tree for the bit lengths */
  3689. X
  3690. Xtypedef struct tree_desc {
  3691. X    ct_data near *dyn_tree;      /* the dynamic tree */
  3692. X    ct_data near *static_tree;   /* corresponding static tree or NULL */
  3693. X    int     near *extra_bits;    /* extra bits for each code or NULL */
  3694. X    int     extra_base;          /* base index for extra_bits */
  3695. X    int     elems;               /* max number of elements in the tree */
  3696. X    int     max_length;          /* max bit length for the codes */
  3697. X    int     max_code;            /* largest code with non zero frequency */
  3698. X} tree_desc;
  3699. X
  3700. Xlocal tree_desc near l_desc =
  3701. X{dyn_ltree, static_ltree, extra_lbits, LITERALS+1, L_CODES, MAX_BITS, 0};
  3702. X
  3703. Xlocal tree_desc near d_desc =
  3704. X{dyn_dtree, static_dtree, extra_dbits, 0,          D_CODES, MAX_BITS, 0};
  3705. X
  3706. Xlocal tree_desc near bl_desc =
  3707. X{bl_tree, NULL,       extra_blbits, 0,         BL_CODES, MAX_BL_BITS, 0};
  3708. X
  3709. X
  3710. Xlocal ush near bl_count[MAX_BITS+1];
  3711. X/* number of codes at each bit length for an optimal tree */
  3712. X
  3713. Xlocal uch near bl_order[BL_CODES]
  3714. X   = {16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15};
  3715. X/* The lengths of the bit length codes are sent in order of decreasing
  3716. X * probability, to avoid transmitting the lengths for unused bit length codes.
  3717. X */
  3718. X
  3719. Xlocal int near heap[2*L_CODES+1]; /* heap used to build the Huffman trees */
  3720. Xlocal int heap_len;               /* number of elements in the heap */
  3721. Xlocal int heap_max;               /* element of largest frequency */
  3722. X/* The sons of heap[n] are heap[2*n] and heap[2*n+1]. heap[0] is not used.
  3723. X * The same heap array is used to build all trees.
  3724. X */
  3725. X
  3726. Xlocal uch near depth[2*L_CODES+1];
  3727. X/* Depth of each subtree used as tie breaker for trees of equal frequency */
  3728. X
  3729. Xlocal uch length_code[MAX_MATCH-MIN_MATCH+1];
  3730. X/* length code for each normalized match length (0 == MIN_MATCH) */
  3731. X
  3732. Xlocal uch dist_code[512];
  3733. X/* distance codes. The first 256 values correspond to the distances
  3734. X * 3 .. 258, the last 256 values correspond to the top 8 bits of
  3735. X * the 15 bit distances.
  3736. X */
  3737. X
  3738. Xlocal int near base_length[LENGTH_CODES];
  3739. X/* First normalized length for each code (0 = MIN_MATCH) */
  3740. X
  3741. Xlocal int near base_dist[D_CODES];
  3742. X/* First normalized distance for each code (0 = distance of 1) */
  3743. X
  3744. X#ifndef DYN_ALLOC
  3745. X  local uch far l_buf[LIT_BUFSIZE];  /* buffer for literals/lengths */
  3746. X  local ush far d_buf[DIST_BUFSIZE]; /* buffer for distances */
  3747. X#else
  3748. X  local uch far *l_buf;
  3749. X  local ush far *d_buf;
  3750. X#endif
  3751. X
  3752. Xlocal uch near flag_buf[(LIT_BUFSIZE/8)];
  3753. X/* flag_buf is a bit array distinguishing literals from lengths in
  3754. X * l_buf, and thus indicating the presence or absence of a distance.
  3755. X */
  3756. X
  3757. Xlocal unsigned last_lit;    /* running index in l_buf */
  3758. Xlocal unsigned last_dist;   /* running index in d_buf */
  3759. Xlocal unsigned last_flags;  /* running index in flag_buf */
  3760. Xlocal uch flags;            /* current flags not yet saved in flag_buf */
  3761. Xlocal uch flag_bit;         /* current bit used in flags */
  3762. X/* bits are filled in flags starting at bit 0 (least significant).
  3763. X * Note: these flags are overkill in the current code since we don't
  3764. X * take advantage of DIST_BUFSIZE == LIT_BUFSIZE.
  3765. X */
  3766. X
  3767. Xlocal ulg opt_len;        /* bit length of current block with optimal trees */
  3768. Xlocal ulg static_len;     /* bit length of current block with static trees */
  3769. X
  3770. Xlocal ulg compressed_len; /* total bit length of compressed file */
  3771. X
  3772. Xlocal ulg input_len;      /* total byte length of input file */
  3773. X/* input_len is for debugging only since we can get it by other means. */
  3774. X
  3775. Xush *file_type;        /* pointer to UNKNOWN, BINARY or ASCII */
  3776. Xint *file_method;      /* pointer to DEFLATE or STORE */
  3777. X
  3778. X#ifdef DEBUG
  3779. Xextern ulg bits_sent;  /* bit length of the compressed data */
  3780. Xextern ulg isize;      /* byte length of input file */
  3781. X#endif
  3782. X
  3783. Xextern long block_start;       /* window offset of current block */
  3784. Xextern unsigned near strstart; /* window offset of current string */
  3785. X
  3786. X/* ===========================================================================
  3787. X * Local (static) routines in this file.
  3788. X */
  3789. X
  3790. Xlocal void init_block     OF((void));
  3791. Xlocal void pqdownheap     OF((ct_data near *tree, int k));
  3792. Xlocal void gen_bitlen     OF((tree_desc near *desc));
  3793. Xlocal void gen_codes      OF((ct_data near *tree, int max_code));
  3794. Xlocal void build_tree     OF((tree_desc near *desc));
  3795. Xlocal void scan_tree      OF((ct_data near *tree, int max_code));
  3796. Xlocal void send_tree      OF((ct_data near *tree, int max_code));
  3797. Xlocal int  build_bl_tree  OF((void));
  3798. Xlocal void send_all_trees OF((int lcodes, int dcodes, int blcodes));
  3799. Xlocal void compress_block OF((ct_data near *ltree, ct_data near *dtree));
  3800. Xlocal void set_file_type  OF((void));
  3801. X
  3802. X
  3803. X#ifndef DEBUG
  3804. X#  define send_code(c, tree) send_bits(tree[c].Code, tree[c].Len)
  3805. X   /* Send a code of the given tree. c and tree must not have side effects */
  3806. X
  3807. X#else /* DEBUG */
  3808. X#  define send_code(c, tree) \
  3809. X     { if (verbose>1) fprintf(stderr,"\ncd %3d ",(c)); \
  3810. X       send_bits(tree[c].Code, tree[c].Len); }
  3811. X#endif
  3812. X
  3813. X#define d_code(dist) \
  3814. X   ((dist) < 256 ? dist_code[dist] : dist_code[256+((dist)>>7)])
  3815. X/* Mapping from a distance to a distance code. dist is the distance - 1 and
  3816. X * must not have side effects. dist_code[256] and dist_code[257] are never
  3817. X * used.
  3818. X */
  3819. X
  3820. X#define MAX(a,b) (a >= b ? a : b)
  3821. X/* the arguments must not have side effects */
  3822. X
  3823. X/* ===========================================================================
  3824. X * Allocate the match buffer, initialize the various tables and save the
  3825. X * location of the internal file attribute (ascii/binary) and method
  3826. X * (DEFLATE/STORE).
  3827. X */
  3828. Xvoid ct_init(attr, method)
  3829. X    ush  *attr;   /* pointer to internal file attribute */
  3830. X    int  *method; /* pointer to compression method */
  3831. X{
  3832. X    int n;        /* iterates over tree elements */
  3833. X    int bits;     /* bit counter */
  3834. X    int length;   /* length value */
  3835. X    int code;     /* code value */
  3836. X    int dist;     /* distance index */
  3837. X
  3838. X    file_type = attr;
  3839. X    file_method = method;
  3840. X    compressed_len = input_len = 0L;
  3841. X        
  3842. X    if (static_dtree[0].Len != 0) return; /* ct_init already called */
  3843. X
  3844. X#ifdef DYN_ALLOC
  3845. X    d_buf = (ush far*) fcalloc(DIST_BUFSIZE, sizeof(ush));
  3846. X    l_buf = (uch far*) fcalloc(LIT_BUFSIZE/2, 2);
  3847. X    /* Avoid using the value 64K on 16 bit machines */
  3848. X    if (l_buf == NULL || d_buf == NULL) error("ct_init: out of memory");
  3849. X#endif
  3850. X
  3851. X    /* Initialize the mapping length (0..255) -> length code (0..28) */
  3852. X    length = 0;
  3853. X    for (code = 0; code < LENGTH_CODES-1; code++) {
  3854. X        base_length[code] = length;
  3855. X        for (n = 0; n < (1<<extra_lbits[code]); n++) {
  3856. X            length_code[length++] = (uch)code;
  3857. X        }
  3858. X    }
  3859. X    Assert (length == 256, "ct_init: length != 256");
  3860. X    /* Note that the length 255 (match length 258) can be represented
  3861. X     * in two different ways: code 284 + 5 bits or code 285, so we
  3862. X     * overwrite length_code[255] to use the best encoding:
  3863. X     */
  3864. X    length_code[length-1] = (uch)code;
  3865. X
  3866. X    /* Initialize the mapping dist (0..32K) -> dist code (0..29) */
  3867. X    dist = 0;
  3868. X    for (code = 0 ; code < 16; code++) {
  3869. X        base_dist[code] = dist;
  3870. X        for (n = 0; n < (1<<extra_dbits[code]); n++) {
  3871. X            dist_code[dist++] = (uch)code;
  3872. X        }
  3873. X    }
  3874. X    Assert (dist == 256, "ct_init: dist != 256");
  3875. X    dist >>= 7; /* from now on, all distances are divided by 128 */
  3876. X    for ( ; code < D_CODES; code++) {
  3877. X        base_dist[code] = dist << 7;
  3878. X        for (n = 0; n < (1<<(extra_dbits[code]-7)); n++) {
  3879. X            dist_code[256 + dist++] = (uch)code;
  3880. X        }
  3881. X    }
  3882. X    Assert (dist == 256, "ct_init: 256+dist != 512");
  3883. X
  3884. X    /* Construct the codes of the static literal tree */
  3885. X    for (bits = 0; bits <= MAX_BITS; bits++) bl_count[bits] = 0;
  3886. X    n = 0;
  3887. X    while (n <= 143) static_ltree[n++].Len = 8, bl_count[8]++;
  3888. X    while (n <= 255) static_ltree[n++].Len = 9, bl_count[9]++;
  3889. X    while (n <= 279) static_ltree[n++].Len = 7, bl_count[7]++;
  3890. X    while (n <= 287) static_ltree[n++].Len = 8, bl_count[8]++;
  3891. X    /* Codes 286 and 287 do not exist, but we must include them in the
  3892. X     * tree construction to get a canonical Huffman tree (longest code
  3893. X     * all ones)
  3894. X     */
  3895. X    gen_codes(static_ltree, L_CODES+1);
  3896. X
  3897. X    /* The static distance tree is trivial: */
  3898. X    for (n = 0; n < D_CODES; n++) {
  3899. X        static_dtree[n].Len = 5;
  3900. X        static_dtree[n].Code = bi_reverse(n, 5);
  3901. X    }
  3902. X
  3903. X    /* Initialize the first block of the first file: */
  3904. X    init_block();
  3905. X}
  3906. X
  3907. X/* ===========================================================================
  3908. X * Initialize a new block.
  3909. X */
  3910. Xlocal void init_block()
  3911. X{
  3912. X    int n; /* iterates over tree elements */
  3913. X
  3914. X    /* Initialize the trees. */
  3915. X    for (n = 0; n < L_CODES;  n++) dyn_ltree[n].Freq = 0;
  3916. X    for (n = 0; n < D_CODES;  n++) dyn_dtree[n].Freq = 0;
  3917. X    for (n = 0; n < BL_CODES; n++) bl_tree[n].Freq = 0;
  3918. X
  3919. X    dyn_ltree[END_BLOCK].Freq = 1;
  3920. X    opt_len = static_len = 0L;
  3921. X    last_lit = last_dist = last_flags = 0;
  3922. X    flags = 0; flag_bit = 1;
  3923. X}
  3924. X
  3925. X#define SMALLEST 1
  3926. X/* Index within the heap array of least frequent node in the Huffman tree */
  3927. X
  3928. X
  3929. X/* ===========================================================================
  3930. X * Remove the smallest element from the heap and recreate the heap with
  3931. X * one less element. Updates heap and heap_len.
  3932. X */
  3933. X#define pqremove(tree, top) \
  3934. X{\
  3935. X    top = heap[SMALLEST]; \
  3936. X    heap[SMALLEST] = heap[heap_len--]; \
  3937. X    pqdownheap(tree, SMALLEST); \
  3938. X}
  3939. X
  3940. X/* ===========================================================================
  3941. X * Compares to subtrees, using the tree depth as tie breaker when
  3942. X * the subtrees have equal frequency. This minimizes the worst case length.
  3943. X */
  3944. X#define smaller(tree, n, m) \
  3945. X   (tree[n].Freq < tree[m].Freq || \
  3946. X   (tree[n].Freq == tree[m].Freq && depth[n] <= depth[m]))
  3947. X
  3948. X/* ===========================================================================
  3949. X * Restore the heap property by moving down the tree starting at node k,
  3950. X * exchanging a node with the smallest of its two sons if necessary, stopping
  3951. X * when the heap property is re-established (each father smaller than its
  3952. X * two sons).
  3953. X */
  3954. Xlocal void pqdownheap(tree, k)
  3955. X    ct_data near *tree;  /* the tree to restore */
  3956. X    int k;               /* node to move down */
  3957. X{
  3958. X    int v = heap[k];
  3959. X    int j = k << 1;  /* left son of k */
  3960. X    while (j <= heap_len) {
  3961. X        /* Set j to the smallest of the two sons: */
  3962. X        if (j < heap_len && smaller(tree, heap[j+1], heap[j])) j++;
  3963. X
  3964. X        /* Exit if v is smaller than both sons */
  3965. X        if (smaller(tree, v, heap[j])) break;
  3966. X
  3967. X        /* Exchange v with the smallest son */
  3968. X        heap[k] = heap[j],  k = j;
  3969. X
  3970. X        /* And continue down the tree, setting j to the left son of k */
  3971. X        j <<= 1;
  3972. X    }
  3973. X    heap[k] = v;
  3974. X}
  3975. X
  3976. X/* ===========================================================================
  3977. X * Compute the optimal bit lengths for a tree and update the total bit length
  3978. X * for the current block.
  3979. X * IN assertion: the fields freq and dad are set, heap[heap_max] and
  3980. X *    above are the tree nodes sorted by increasing frequency.
  3981. X * OUT assertions: the field len is set to the optimal bit length, the
  3982. X *     array bl_count contains the frequencies for each bit length.
  3983. X *     The length opt_len is updated; static_len is also updated if stree is
  3984. X *     not null.
  3985. X */
  3986. Xlocal void gen_bitlen(desc)
  3987. X    tree_desc near *desc; /* the tree descriptor */
  3988. X{
  3989. X    ct_data near *tree  = desc->dyn_tree;
  3990. X    int near *extra     = desc->extra_bits;
  3991. X    int base            = desc->extra_base;
  3992. X    int max_code        = desc->max_code;
  3993. X    int max_length      = desc->max_length;
  3994. X    ct_data near *stree = desc->static_tree;
  3995. X    int h;              /* heap index */
  3996. X    int n, m;           /* iterate over the tree elements */
  3997. X    int bits;           /* bit length */
  3998. X    int xbits;          /* extra bits */
  3999. X    ush f;              /* frequency */
  4000. X    int overflow = 0;   /* number of elements with bit length too large */
  4001. X
  4002. X    for (bits = 0; bits <= MAX_BITS; bits++) bl_count[bits] = 0;
  4003. X
  4004. X    /* In a first pass, compute the optimal bit lengths (which may
  4005. X     * overflow in the case of the bit length tree).
  4006. X     */
  4007. X    tree[heap[heap_max]].Len = 0; /* root of the heap */
  4008. X
  4009. X    for (h = heap_max+1; h < HEAP_SIZE; h++) {
  4010. X        n = heap[h];
  4011. X        bits = tree[tree[n].Dad].Len + 1;
  4012. X        if (bits > max_length) bits = max_length, overflow++;
  4013. X        tree[n].Len = bits;
  4014. X        /* We overwrite tree[n].Dad which is no longer needed */
  4015. X
  4016. X        if (n > max_code) continue; /* not a leaf node */
  4017. X
  4018. X        bl_count[bits]++;
  4019. X        xbits = 0;
  4020. X        if (n >= base) xbits = extra[n-base];
  4021. X        f = tree[n].Freq;
  4022. X        opt_len += (ulg)f * (bits + xbits);
  4023. X        if (stree) static_len += (ulg)f * (stree[n].Len + xbits);
  4024. X    }
  4025. X    if (overflow == 0) return;
  4026. X
  4027. X    Trace((stderr,"\nbit length overflow\n"));
  4028. X    /* This happens for example on obj2 and pic of the Calgary corpus */
  4029. X
  4030. X    /* Find the first bit length which could increase: */
  4031. X    do {
  4032. X        bits = max_length-1;
  4033. X        while (bl_count[bits] == 0) bits--;
  4034. X        bl_count[bits]--;      /* move one leaf down the tree */
  4035. X        bl_count[bits+1] += 2; /* move one overflow item as its brother */
  4036. X        bl_count[max_length]--;
  4037. X        /* The brother of the overflow item also moves one step up,
  4038. X         * but this does not affect bl_count[max_length]
  4039. X         */
  4040. X        overflow -= 2;
  4041. X    } while (overflow > 0);
  4042. X
  4043. X    /* Now recompute all bit lengths, scanning in increasing frequency.
  4044. X     * h is still equal to HEAP_SIZE. (It is simpler to reconstruct all
  4045. X     * lengths instead of fixing only the wrong ones. This idea is taken
  4046. X     * from 'ar' written by Haruhiko Okumura.)
  4047. X     */
  4048. X    for (bits = max_length; bits != 0; bits--) {
  4049. X        n = bl_count[bits];
  4050. X        while (n != 0) {
  4051. X            m = heap[--h];
  4052. X            if (m > max_code) continue;
  4053. X            if (tree[m].Len != (unsigned) bits) {
  4054. X                Trace((stderr,"code %d bits %d->%d\n", m, tree[m].Len, bits));
  4055. X                opt_len += ((long)bits-(long)tree[m].Len)*(long)tree[m].Freq;
  4056. X                tree[m].Len = bits;
  4057. X            }
  4058. X            n--;
  4059. X        }
  4060. X    }
  4061. X}
  4062. X
  4063. X/* ===========================================================================
  4064. X * Generate the codes for a given tree and bit counts (which need not be
  4065. X * optimal).
  4066. X * IN assertion: the array bl_count contains the bit length statistics for
  4067. X * the given tree and the field len is set for all tree elements.
  4068. X * OUT assertion: the field code is set for all tree elements of non
  4069. X *     zero code length.
  4070. X */
  4071. Xlocal void gen_codes (tree, max_code)
  4072. X    ct_data near *tree;        /* the tree to decorate */
  4073. X    int max_code;              /* largest code with non zero frequency */
  4074. X{
  4075. X    ush next_code[MAX_BITS+1]; /* next code value for each bit length */
  4076. X    ush code = 0;              /* running code value */
  4077. X    int bits;                  /* bit index */
  4078. X    int n;                     /* code index */
  4079. X
  4080. X    /* The distribution counts are first used to generate the code values
  4081. X     * without bit reversal.
  4082. X     */
  4083. X    for (bits = 1; bits <= MAX_BITS; bits++) {
  4084. X        next_code[bits] = code = (code + bl_count[bits-1]) << 1;
  4085. X    }
  4086. X    /* Check that the bit counts in bl_count are consistent. The last code
  4087. X     * must be all ones.
  4088. X     */
  4089. X    Assert (code + bl_count[MAX_BITS]-1 == (1<<MAX_BITS)-1,
  4090. X            "inconsistent bit counts");
  4091. X    Tracev((stderr,"\ngen_codes: max_code %d ", max_code));
  4092. X
  4093. X    for (n = 0;  n <= max_code; n++) {
  4094. X        int len = tree[n].Len;
  4095. X        if (len == 0) continue;
  4096. X        /* Now reverse the bits */
  4097. X        tree[n].Code = bi_reverse(next_code[len]++, len);
  4098. X
  4099. X        Tracec(tree != static_ltree, (stderr,"\nn %3d %c l %2d c %4x (%x) ",
  4100. X             n, (isgraph(n) ? n : ' '), len, tree[n].Code, next_code[len]-1));
  4101. X    }
  4102. X}
  4103. X
  4104. X/* ===========================================================================
  4105. X * Construct one Huffman tree and assigns the code bit strings and lengths.
  4106. X * Update the total bit length for the current block.
  4107. X * IN assertion: the field freq is set for all tree elements.
  4108. X * OUT assertions: the fields len and code are set to the optimal bit length
  4109. X *     and corresponding code. The length opt_len is updated; static_len is
  4110. X *     also updated if stree is not null. The field max_code is set.
  4111. X */
  4112. Xlocal void build_tree(desc)
  4113. X    tree_desc near *desc; /* the tree descriptor */
  4114. X{
  4115. X    ct_data near *tree   = desc->dyn_tree;
  4116. X    ct_data near *stree  = desc->static_tree;
  4117. X    int elems            = desc->elems;
  4118. X    int n, m;          /* iterate over heap elements */
  4119. X    int max_code = -1; /* largest code with non zero frequency */
  4120. X    int node = elems;  /* next internal node of the tree */
  4121. X
  4122. X    /* Construct the initial heap, with least frequent element in
  4123. X     * heap[SMALLEST]. The sons of heap[n] are heap[2*n] and heap[2*n+1].
  4124. X     * heap[0] is not used.
  4125. X     */
  4126. X    heap_len = 0, heap_max = HEAP_SIZE;
  4127. X
  4128. X    for (n = 0; n < elems; n++) {
  4129. X        if (tree[n].Freq != 0) {
  4130. X            heap[++heap_len] = max_code = n;
  4131. X            depth[n] = 0;
  4132. X        } else {
  4133. X            tree[n].Len = 0;
  4134. X        }
  4135. X    }
  4136. X
  4137. X    /* The pkzip format requires that at least one distance code exists,
  4138. X     * and that at least one bit should be sent even if there is only one
  4139. X     * possible code. So to avoid special checks later on we force at least
  4140. X     * two codes of non zero frequency.
  4141. X     */
  4142. X    while (heap_len < 2) {
  4143. X        int new = heap[++heap_len] = (max_code < 2 ? ++max_code : 0);
  4144. X        tree[new].Freq = 1;
  4145. X        depth[new] = 0;
  4146. X        opt_len--; if (stree) static_len -= stree[new].Len;
  4147. X        /* new is 0 or 1 so it does not have extra bits */
  4148. X    }
  4149. X    desc->max_code = max_code;
  4150. X
  4151. X    /* The elements heap[heap_len/2+1 .. heap_len] are leaves of the tree,
  4152. X     * establish sub-heaps of increasing lengths:
  4153. X     */
  4154. X    for (n = heap_len/2; n >= 1; n--) pqdownheap(tree, n);
  4155. X
  4156. X    /* Construct the Huffman tree by repeatedly combining the least two
  4157. X     * frequent nodes.
  4158. X     */
  4159. X    do {
  4160. X        pqremove(tree, n);   /* n = node of least frequency */
  4161. X        m = heap[SMALLEST];  /* m = node of next least frequency */
  4162. X
  4163. X        heap[--heap_max] = n; /* keep the nodes sorted by frequency */
  4164. X        heap[--heap_max] = m;
  4165. X
  4166. X        /* Create a new node father of n and m */
  4167. X        tree[node].Freq = tree[n].Freq + tree[m].Freq;
  4168. X        depth[node] = (uch) (MAX(depth[n], depth[m]) + 1);
  4169. X        tree[n].Dad = tree[m].Dad = node;
  4170. X#ifdef DUMP_BL_TREE
  4171. X        if (tree == bl_tree) {
  4172. X            fprintf(stderr,"\nnode %d(%d), sons %d(%d) %d(%d)",
  4173. X                    node, tree[node].Freq, n, tree[n].Freq, m, tree[m].Freq);
  4174. X        }
  4175. X#endif
  4176. X        /* and insert the new node in the heap */
  4177. X        heap[SMALLEST] = node++;
  4178. X        pqdownheap(tree, SMALLEST);
  4179. X
  4180. X    } while (heap_len >= 2);
  4181. X
  4182. X    heap[--heap_max] = heap[SMALLEST];
  4183. X
  4184. X    /* At this point, the fields freq and dad are set. We can now
  4185. X     * generate the bit lengths.
  4186. X     */
  4187. X    gen_bitlen(desc);
  4188. X
  4189. X    /* The field len is now set, we can generate the bit codes */
  4190. X    gen_codes (tree, max_code);
  4191. X}
  4192. X
  4193. X/* ===========================================================================
  4194. X * Scan a literal or distance tree to determine the frequencies of the codes
  4195. X * in the bit length tree. Updates opt_len to take into account the repeat
  4196. X * counts. (The contribution of the bit length codes will be added later
  4197. X * during the construction of bl_tree.)
  4198. X */
  4199. Xlocal void scan_tree (tree, max_code)
  4200. X    ct_data near *tree; /* the tree to be scanned */
  4201. X    int max_code;       /* and its largest code of non zero frequency */
  4202. X{
  4203. X    int n;                     /* iterates over all tree elements */
  4204. X    int prevlen = -1;          /* last emitted length */
  4205. X    int curlen;                /* length of current code */
  4206. X    int nextlen = tree[0].Len; /* length of next code */
  4207. X    int count = 0;             /* repeat count of the current code */
  4208. X    int max_count = 7;         /* max repeat count */
  4209. X    int min_count = 4;         /* min repeat count */
  4210. X
  4211. X    if (nextlen == 0) max_count = 138, min_count = 3;
  4212. X    tree[max_code+1].Len = (ush)-1; /* guard */
  4213. X
  4214. X    for (n = 0; n <= max_code; n++) {
  4215. X        curlen = nextlen; nextlen = tree[n+1].Len;
  4216. X        if (++count < max_count && curlen == nextlen) {
  4217. X            continue;
  4218. X        } else if (count < min_count) {
  4219. X            bl_tree[curlen].Freq += count;
  4220. X        } else if (curlen != 0) {
  4221. X            if (curlen != prevlen) bl_tree[curlen].Freq++;
  4222. X            bl_tree[REP_3_6].Freq++;
  4223. X        } else if (count <= 10) {
  4224. X            bl_tree[REPZ_3_10].Freq++;
  4225. X        } else {
  4226. X            bl_tree[REPZ_11_138].Freq++;
  4227. X        }
  4228. X        count = 0; prevlen = curlen;
  4229. X        if (nextlen == 0) {
  4230. X            max_count = 138, min_count = 3;
  4231. X        } else if (curlen == nextlen) {
  4232. X            max_count = 6, min_count = 3;
  4233. X        } else {
  4234. X            max_count = 7, min_count = 4;
  4235. X        }
  4236. X    }
  4237. X}
  4238. X
  4239. X/* ===========================================================================
  4240. X * Send a literal or distance tree in compressed form, using the codes in
  4241. X * bl_tree.
  4242. X */
  4243. Xlocal void send_tree (tree, max_code)
  4244. X    ct_data near *tree; /* the tree to be scanned */
  4245. X    int max_code;       /* and its largest code of non zero frequency */
  4246. X{
  4247. X    int n;                     /* iterates over all tree elements */
  4248. X    int prevlen = -1;          /* last emitted length */
  4249. X    int curlen;                /* length of current code */
  4250. X    int nextlen = tree[0].Len; /* length of next code */
  4251. X    int count = 0;             /* repeat count of the current code */
  4252. X    int max_count = 7;         /* max repeat count */
  4253. X    int min_count = 4;         /* min repeat count */
  4254. X
  4255. X    /* tree[max_code+1].Len = -1; */  /* guard already set */
  4256. X    if (nextlen == 0) max_count = 138, min_count = 3;
  4257. X
  4258. X    for (n = 0; n <= max_code; n++) {
  4259. X        curlen = nextlen; nextlen = tree[n+1].Len;
  4260. X        if (++count < max_count && curlen == nextlen) {
  4261. X            continue;
  4262. X        } else if (count < min_count) {
  4263. X            do { send_code(curlen, bl_tree); } while (--count != 0);
  4264. X
  4265. X        } else if (curlen != 0) {
  4266. X            if (curlen != prevlen) {
  4267. X                send_code(curlen, bl_tree); count--;
  4268. X            }
  4269. X            Assert(count >= 3 && count <= 6, " 3_6?");
  4270. X            send_code(REP_3_6, bl_tree); send_bits(count-3, 2);
  4271. X
  4272. X        } else if (count <= 10) {
  4273. X            send_code(REPZ_3_10, bl_tree); send_bits(count-3, 3);
  4274. X
  4275. X        } else {
  4276. X            send_code(REPZ_11_138, bl_tree); send_bits(count-11, 7);
  4277. X        }
  4278. X        count = 0; prevlen = curlen;
  4279. X        if (nextlen == 0) {
  4280. X            max_count = 138, min_count = 3;
  4281. X        } else if (curlen == nextlen) {
  4282. X            max_count = 6, min_count = 3;
  4283. X        } else {
  4284. X            max_count = 7, min_count = 4;
  4285. X        }
  4286. X    }
  4287. X}
  4288. X
  4289. X/* ===========================================================================
  4290. X * Construct the Huffman tree for the bit lengths and return the index in
  4291. X * bl_order of the last bit length code to send.
  4292. X */
  4293. Xlocal int build_bl_tree()
  4294. X{
  4295. X    int max_blindex;  /* index of last bit length code of non zero freq */
  4296. X
  4297. X    /* Determine the bit length frequencies for literal and distance trees */
  4298. X    scan_tree(dyn_ltree, l_desc.max_code);
  4299. X    scan_tree(dyn_dtree, d_desc.max_code);
  4300. X
  4301. X    /* Build the bit length tree: */
  4302. X    build_tree(&bl_desc);
  4303. X    /* opt_len now includes the length of the tree representations, except
  4304. X     * the lengths of the bit lengths codes and the 5+5+4 bits for the counts.
  4305. X     */
  4306. X
  4307. X    /* Determine the number of bit length codes to send. The pkzip format
  4308. X     * requires that at least 4 bit length codes be sent. (appnote.txt says
  4309. X     * 3 but the actual value used is 4.)
  4310. X     */
  4311. X    for (max_blindex = BL_CODES-1; max_blindex >= 3; max_blindex--) {
  4312. X        if (bl_tree[bl_order[max_blindex]].Len != 0) break;
  4313. X    }
  4314. X    /* Update opt_len to include the bit length tree and counts */
  4315. X    opt_len += 3*(max_blindex+1) + 5+5+4;
  4316. X    Tracev((stderr, "\ndyn trees: dyn %ld, stat %ld", opt_len, static_len));
  4317. X
  4318. X    return max_blindex;
  4319. X}
  4320. X
  4321. X/* ===========================================================================
  4322. X * Send the header for a block using dynamic Huffman trees: the counts, the
  4323. X * lengths of the bit length codes, the literal tree and the distance tree.
  4324. X * IN assertion: lcodes >= 257, dcodes >= 1, blcodes >= 4.
  4325. X */
  4326. Xlocal void send_all_trees(lcodes, dcodes, blcodes)
  4327. X    int lcodes, dcodes, blcodes; /* number of codes for each tree */
  4328. X{
  4329. X    int rank;                    /* index in bl_order */
  4330. X
  4331. X    Assert (lcodes >= 257 && dcodes >= 1 && blcodes >= 4, "not enough codes");
  4332. X    Assert (lcodes <= L_CODES && dcodes <= D_CODES && blcodes <= BL_CODES,
  4333. X            "too many codes");
  4334. X    Tracev((stderr, "\nbl counts: "));
  4335. X    send_bits(lcodes-257, 5); /* not -255 as stated in appnote.txt */
  4336. X    send_bits(dcodes-1,   5);
  4337. X    send_bits(blcodes-4,  4); /* not -3 as stated in appnote.txt */
  4338. X    for (rank = 0; rank < blcodes; rank++) {
  4339. X        Tracev((stderr, "\nbl code %2d ", bl_order[rank]));
  4340. X        send_bits(bl_tree[bl_order[rank]].Len, 3);
  4341. X    }
  4342. X    Tracev((stderr, "\nbl tree: sent %ld", bits_sent));
  4343. X
  4344. X    send_tree(dyn_ltree, lcodes-1); /* send the literal tree */
  4345. X    Tracev((stderr, "\nlit tree: sent %ld", bits_sent));
  4346. X
  4347. X    send_tree(dyn_dtree, dcodes-1); /* send the distance tree */
  4348. X    Tracev((stderr, "\ndist tree: sent %ld", bits_sent));
  4349. X}
  4350. X
  4351. X/* ===========================================================================
  4352. X * Determine the best encoding for the current block: dynamic trees, static
  4353. X * trees or store, and output the encoded block to the zip file. This function
  4354. X * returns the total compressed length for the file so far.
  4355. X */
  4356. Xulg flush_block(buf, stored_len, eof)
  4357. X    char *buf;        /* input block, or NULL if too old */
  4358. X    ulg stored_len;   /* length of input block */
  4359. X    int eof;          /* true if this is the last block for a file */
  4360. X{
  4361. X    ulg opt_lenb, static_lenb; /* opt_len and static_len in bytes */
  4362. X    int max_blindex;  /* index of last bit length code of non zero freq */
  4363. X
  4364. X    flag_buf[last_flags] = flags; /* Save the flags for the last 8 items */
  4365. X
  4366. X     /* Check if the file is ascii or binary */
  4367. X    if (*file_type == (ush)UNKNOWN) set_file_type();
  4368. X
  4369. X    /* Construct the literal and distance trees */
  4370. X    build_tree(&l_desc);
  4371. X    Tracev((stderr, "\nlit data: dyn %ld, stat %ld", opt_len, static_len));
  4372. X
  4373. X    build_tree(&d_desc);
  4374. X    Tracev((stderr, "\ndist data: dyn %ld, stat %ld", opt_len, static_len));
  4375. X    /* At this point, opt_len and static_len are the total bit lengths of
  4376. X     * the compressed block data, excluding the tree representations.
  4377. X     */
  4378. X
  4379. X    /* Build the bit length tree for the above two trees, and get the index
  4380. X     * in bl_order of the last bit length code to send.
  4381. X     */
  4382. X    max_blindex = build_bl_tree();
  4383. X
  4384. X    /* Determine the best encoding. Compute first the block length in bytes */
  4385. X    opt_lenb = (opt_len+3+7)>>3;
  4386. X    static_lenb = (static_len+3+7)>>3;
  4387. X    input_len += stored_len; /* for debugging only */
  4388. X
  4389. X    Trace((stderr, "\nopt %lu(%lu) stat %lu(%lu) stored %lu lit %u dist %u ",
  4390. X            opt_lenb, opt_len, static_lenb, static_len, stored_len,
  4391. X            last_lit, last_dist));
  4392. X
  4393. X    if (static_lenb <= opt_lenb) opt_lenb = static_lenb;
  4394. X
  4395. X    /* If compression failed and this is the first and last block,
  4396. X     * and if the zip file can be seeked (to rewrite the local header),
  4397. X     * the whole file is transformed into a stored file:
  4398. X     */
  4399. X#ifdef FORCE_METHOD
  4400. X    if (level == 1 && eof && compressed_len == 0L) { /* force stored file */
  4401. X#else
  4402. X    if (stored_len <= opt_lenb && eof && compressed_len == 0L && seekable()) {
  4403. X#endif
  4404. X        /* Since LIT_BUFSIZE <= 2*WSIZE, the input data must be there: */
  4405. X        if (buf == NULL) error ("block vanished");
  4406. X
  4407. X        copy_block(buf, (unsigned)stored_len, 0); /* without header */
  4408. X        compressed_len = stored_len << 3;
  4409. X        *file_method = STORE;
  4410. X
  4411. X#ifdef FORCE_METHOD
  4412. X    } else if (level == 2 && buf != NULL) { /* force stored block */
  4413. X#else
  4414. X    } else if (stored_len+4 <= opt_lenb && buf != NULL) {
  4415. X                       /* 4: two words for the lengths */
  4416. X#endif
  4417. X        /* The test buf != NULL is only necessary if LIT_BUFSIZE > WSIZE.
  4418. X         * Otherwise we can't have processed more than WSIZE input bytes since
  4419. X         * the last block flush, because compression would have been
  4420. X         * successful. If LIT_BUFSIZE <= WSIZE, it is never too late to
  4421. X         * transform a block into a stored block.
  4422. X         */
  4423. X        send_bits((STORED_BLOCK<<1)+eof, 3);  /* send block type */
  4424. X        compressed_len = (compressed_len + 3 + 7) & ~7L;
  4425. X        compressed_len += (stored_len + 4) << 3;
  4426. X
  4427. X        copy_block(buf, (unsigned)stored_len, 1); /* with header */
  4428. X
  4429. X#ifdef FORCE_METHOD
  4430. X    } else if (level == 3) { /* force static trees */
  4431. X#else
  4432. X    } else if (static_lenb == opt_lenb) {
  4433. X#endif
  4434. X        send_bits((STATIC_TREES<<1)+eof, 3);
  4435. X        compress_block(static_ltree, static_dtree);
  4436. X        compressed_len += 3 + static_len;
  4437. X    } else {
  4438. X        send_bits((DYN_TREES<<1)+eof, 3);
  4439. X        send_all_trees(l_desc.max_code+1, d_desc.max_code+1, max_blindex+1);
  4440. X        compress_block(dyn_ltree, dyn_dtree);
  4441. X        compressed_len += 3 + opt_len;
  4442. X    }
  4443. X    Assert (compressed_len == bits_sent, "bad compressed size");
  4444. X    init_block();
  4445. X
  4446. X    if (eof) {
  4447. X        Assert (input_len == isize, "bad input size");
  4448. X        bi_windup();
  4449. X        compressed_len += 7;  /* align on byte boundary */
  4450. X    }
  4451. X    Tracev((stderr,"\ncomprlen %lu(%lu) ", compressed_len>>3,
  4452. X           compressed_len-7*eof));
  4453. X
  4454. X    return compressed_len >> 3;
  4455. X}
  4456. X
  4457. X/* ===========================================================================
  4458. X * Save the match info and tally the frequency counts. Return true if
  4459. X * the current block must be flushed.
  4460. X */
  4461. Xint ct_tally (dist, lc)
  4462. X    int dist;  /* distance of matched string */
  4463. X    int lc;    /* match length-MIN_MATCH or unmatched char (if dist==0) */
  4464. X{
  4465. X    l_buf[last_lit++] = (uch)lc;
  4466. X    if (dist == 0) {
  4467. X        /* lc is the unmatched char */
  4468. X        dyn_ltree[lc].Freq++;
  4469. X    } else {
  4470. X        /* Here, lc is the match length - MIN_MATCH */
  4471. X        dist--;             /* dist = match distance - 1 */
  4472. X        Assert((ush)dist < (ush)MAX_DIST &&
  4473. X               (ush)lc <= (ush)(MAX_MATCH-MIN_MATCH) &&
  4474. X               (ush)d_code(dist) < (ush)D_CODES,  "ct_tally: bad match");
  4475. X
  4476. X        dyn_ltree[length_code[lc]+LITERALS+1].Freq++;
  4477. X        dyn_dtree[d_code(dist)].Freq++;
  4478. X
  4479. X        d_buf[last_dist++] = dist;
  4480. X        flags |= flag_bit;
  4481. X    }
  4482. X    flag_bit <<= 1;
  4483. X
  4484. X    /* Output the flags if they fill a byte: */
  4485. X    if ((last_lit & 7) == 0) {
  4486. X        flag_buf[last_flags++] = flags;
  4487. X        flags = 0, flag_bit = 1;
  4488. X    }
  4489. X    /* Try to guess if it is profitable to stop the current block here */
  4490. X    if (level > 2 && (last_lit & 0xfff) == 0) {
  4491. X        /* Compute an upper bound for the compressed length */
  4492. X        ulg out_length = (ulg)last_lit*8L;
  4493. X        ulg in_length = (ulg)strstart-block_start;
  4494. X        int dcode;
  4495. X        for (dcode = 0; dcode < D_CODES; dcode++) {
  4496. X            out_length += (ulg)dyn_dtree[dcode].Freq*(5L+extra_dbits[dcode]);
  4497. X        }
  4498. X        out_length >>= 3;
  4499. X        Trace((stderr,"\nlast_lit %u, last_dist %u, in %ld, out ~%ld(%ld%%) ",
  4500. X               last_lit, last_dist, in_length, out_length,
  4501. X               100L - out_length*100L/in_length));
  4502. X        if (last_dist < last_lit/2 && out_length < in_length/2) return 1;
  4503. X    }
  4504. X    return (last_lit == LIT_BUFSIZE-1 || last_dist == DIST_BUFSIZE);
  4505. X    /* We avoid equality with LIT_BUFSIZE because of wraparound at 64K
  4506. X     * on 16 bit machines and because stored blocks are restricted to
  4507. X     * 64K-1 bytes.
  4508. X     */
  4509. X}
  4510. X
  4511. X/* ===========================================================================
  4512. X * Send the block data compressed using the given Huffman trees
  4513. X */
  4514. Xlocal void compress_block(ltree, dtree)
  4515. X    ct_data near *ltree; /* literal tree */
  4516. X    ct_data near *dtree; /* distance tree */
  4517. X{
  4518. X    unsigned dist;      /* distance of matched string */
  4519. X    int lc;             /* match length or unmatched char (if dist == 0) */
  4520. X    unsigned lx = 0;    /* running index in l_buf */
  4521. X    unsigned dx = 0;    /* running index in d_buf */
  4522. X    unsigned fx = 0;    /* running index in flag_buf */
  4523. X    uch flag = 0;       /* current flags */
  4524. X    unsigned code;      /* the code to send */
  4525. X    int extra;          /* number of extra bits to send */
  4526. X
  4527. X    if (last_lit != 0) do {
  4528. X        if ((lx & 7) == 0) flag = flag_buf[fx++];
  4529. X        lc = l_buf[lx++];
  4530. X        if ((flag & 1) == 0) {
  4531. X            send_code(lc, ltree); /* send a literal byte */
  4532. X            Tracecv(isgraph(lc), (stderr," '%c' ", lc));
  4533. X        } else {
  4534. X            /* Here, lc is the match length - MIN_MATCH */
  4535. X            code = length_code[lc];
  4536. X            send_code(code+LITERALS+1, ltree); /* send the length code */
  4537. X            extra = extra_lbits[code];
  4538. X            if (extra != 0) {
  4539. X                lc -= base_length[code];
  4540. X                send_bits(lc, extra);        /* send the extra length bits */
  4541. X            }
  4542. X            dist = d_buf[dx++];
  4543. X            /* Here, dist is the match distance - 1 */
  4544. X            code = d_code(dist);
  4545. X            Assert (code < D_CODES, "bad d_code");
  4546. X
  4547. X            send_code(code, dtree);       /* send the distance code */
  4548. X            extra = extra_dbits[code];
  4549. X            if (extra != 0) {
  4550. X                dist -= base_dist[code];
  4551. X                send_bits(dist, extra);   /* send the extra distance bits */
  4552. X            }
  4553. X        } /* literal or match pair ? */
  4554. X        flag >>= 1;
  4555. X    } while (lx < last_lit);
  4556. X
  4557. X    send_code(END_BLOCK, ltree);
  4558. X}
  4559. X
  4560. X/* ===========================================================================
  4561. X * Set the file type to ASCII or BINARY, using a crude approximation:
  4562. X * binary if more than 20% of the bytes are <= 6 or >= 128, ascii otherwise.
  4563. X * IN assertion: the fields freq of dyn_ltree are set and the total of all
  4564. X * frequencies does not exceed 64K (to fit in an int on 16 bit machines).
  4565. X */
  4566. Xlocal void set_file_type()
  4567. X{
  4568. X    int n = 0;
  4569. X    unsigned ascii_freq = 0;
  4570. X    unsigned bin_freq = 0;
  4571. X    while (n < 7)        bin_freq += dyn_ltree[n++].Freq;
  4572. X    while (n < 128)    ascii_freq += dyn_ltree[n++].Freq;
  4573. X    while (n < LITERALS) bin_freq += dyn_ltree[n++].Freq;
  4574. X    *file_type = bin_freq > (ascii_freq >> 2) ? BINARY : ASCII;
  4575. X    if (*file_type == BINARY && translate_eol) {
  4576. X        warn("-l used on binary file", "");
  4577. X    }
  4578. X}
  4579. END_OF_FILE
  4580.   if test 40777 -ne `wc -c <'trees.c'`; then
  4581.     echo shar: \"'trees.c'\" unpacked with wrong size!
  4582.   fi
  4583.   # end of 'trees.c'
  4584. fi
  4585. if test -f 'util.c' -a "${1}" != "-c" ; then 
  4586.   echo shar: Will not clobber existing file \"'util.c'\"
  4587. else
  4588.   echo shar: Extracting \"'util.c'\" \(12887 characters\)
  4589.   sed "s/^X//" >'util.c' <<'END_OF_FILE'
  4590. X/*
  4591. X
  4592. X Copyright (C) 1990-1992 Mark Adler, Richard B. Wales, Jean-loup Gailly,
  4593. X Kai Uwe Rommel and Igor Mandrichenko.
  4594. X Permission is granted to any individual or institution to use, copy, or
  4595. X redistribute this software so long as all of the original files are included
  4596. X unmodified, that it is not sold for profit, and that this copyright notice
  4597. X is retained.
  4598. X
  4599. X*/
  4600. X
  4601. X/*
  4602. X *  util.c by Mark Adler.
  4603. X */
  4604. X
  4605. X#include "zip.h"
  4606. X#include <ctype.h>
  4607. X
  4608. X#if defined(MSDOS) && !defined(OS2) && !defined(__GO32__) && !defined(WIN32)
  4609. X#  include <dos.h>
  4610. X#endif
  4611. X
  4612. Xuch upper[256], lower[256];
  4613. X/* Country-dependent case map table */
  4614. X
  4615. X
  4616. X#ifndef UTIL /* UTIL picks out namecmp code (all utils) and crc32 (zipcloak) */
  4617. X
  4618. X/* Local functions */
  4619. X#ifdef PROTO
  4620. X  local int recmatch(char *, char *);
  4621. X  local unsigned ident(unsigned chr);
  4622. X#endif /* PROTO */
  4623. X
  4624. Xchar *isshexp(p)
  4625. Xchar *p;                /* candidate sh expression */
  4626. X/* If p is a sh expression, a pointer to the first special character is
  4627. X   returned.  Otherwise, NULL is returned. */
  4628. X{
  4629. X  for (; *p; p++)
  4630. X    if (*p == '\\' && *(p+1))
  4631. X      p++;
  4632. X#ifdef VMS
  4633. X    else if (*p == '%' || *p == '*')
  4634. X#else /* !VMS */
  4635. X    else if (*p == '?' || *p == '*' || *p == '[')
  4636. X#endif /* ?VMS */
  4637. X      return p;
  4638. X  return NULL;
  4639. X}
  4640. X
  4641. X
  4642. Xlocal int recmatch(p, s)
  4643. Xchar *p;                /* sh pattern to match */
  4644. Xchar *s;                /* string to match it to */
  4645. X/* Recursively compare the sh pattern p with the string s and return 1 if
  4646. X   they match, and 0 or 2 if they don't or if there is a syntax error in the
  4647. X   pattern.  This routine recurses on itself no deeper than the number of
  4648. X   characters in the pattern. */
  4649. X{
  4650. X  int c;                /* pattern char or start of range in [-] loop */ 
  4651. X
  4652. X  /* Get first character, the pattern for new recmatch calls follows */
  4653. X  c = *p++;
  4654. X
  4655. X  /* If that was the end of the pattern, match if string empty too */
  4656. X  if (c == 0)
  4657. X    return *s == 0;
  4658. X
  4659. X  /* '?' (or '%') matches any character (but not an empty string) */
  4660. X#ifdef VMS
  4661. X  if (c == '%')
  4662. X#else /* !VMS */
  4663. X  if (c == '?')
  4664. X#endif /* ?VMS */
  4665. X    return *s ? recmatch(p, s + 1) : 0;
  4666. X
  4667. X  /* '*' matches any number of characters, including zero */
  4668. X  if (c == '*')
  4669. X  {
  4670. X    if (*p == 0)
  4671. X      return 1;
  4672. X    for (; *s; s++)
  4673. X      if ((c = recmatch(p, s)) != 0)
  4674. X        return c;
  4675. X    return 2;           /* 2 means give up--shmatch will return false */
  4676. X  }
  4677. X
  4678. X#ifndef VMS             /* No bracket matching in VMS */
  4679. X  /* Parse and process the list of characters and ranges in brackets */
  4680. X  if (c == '[')
  4681. X  {
  4682. X    int e;              /* flag true if next char to be taken literally */
  4683. X    char *q;            /* pointer to end of [-] group */
  4684. X    int r;              /* flag true to match anything but the range */
  4685. X
  4686. X    if (*s == 0)                        /* need a character to match */
  4687. X      return 0;
  4688. X    p += (r = *p == '!');               /* see if reverse */
  4689. X    for (q = p, e = 0; *q; q++)         /* find closing bracket */
  4690. X      if (e)
  4691. X        e = 0;
  4692. X      else
  4693. X        if (*q == '\\')
  4694. X          e = 1;
  4695. X        else if (*q == ']')
  4696. X          break;
  4697. X    if (*q != ']')                      /* nothing matches if bad syntax */
  4698. X      return 0;
  4699. X    for (c = 0, e = *p == '-'; p < q; p++)      /* go through the list */
  4700. X    {
  4701. X      if (e == 0 && *p == '\\')         /* set escape flag if \ */
  4702. X        e = 1;
  4703. X      else if (e == 0 && *p == '-')     /* set start of range if - */
  4704. X        c = *(p-1);
  4705. X      else
  4706. X      {
  4707. X        if (*(p+1) != '-')
  4708. X          for (c = c ? c : *p; c <= *p; c++)    /* compare range */
  4709. X            if (case_map(c) == case_map(*s))
  4710. X              return r ? 0 : recmatch(q + 1, s + 1);
  4711. X        c = e = 0;                      /* clear range, escape flags */
  4712. X      }
  4713. X    }
  4714. X    return r ? recmatch(q + 1, s + 1) : 0;      /* bracket match failed */
  4715. X  }
  4716. X#endif /* !VMS */
  4717. X
  4718. X  /* If escape ('\'), just compare next character */
  4719. X  if (c == '\\')
  4720. X    if ((c = *p++) == 0)                /* if \ at end, then syntax error */
  4721. X      return 0;
  4722. X
  4723. X  /* Just a character--compare it */
  4724. X  return case_map(c) == case_map(*s) ? recmatch(p, ++s) : 0;
  4725. X}
  4726. X
  4727. X
  4728. Xint shmatch(p, s)
  4729. Xchar *p;                /* sh pattern to match */
  4730. Xchar *s;                /* string to match it to */
  4731. X/* Compare the sh pattern p with the string s and return true if they match,
  4732. X   false if they don't or if there is a syntax error in the pattern. */
  4733. X{
  4734. X  return recmatch(p, s) == 1;
  4735. X}
  4736. X
  4737. X
  4738. X#ifdef MSDOS
  4739. X
  4740. Xint dosmatch(p, s)
  4741. Xchar *p;                /* dos pattern to match */
  4742. Xchar *s;                /* string to match it to */
  4743. X/* Break the pattern and string into name and extension parts and match
  4744. X   each separately using shmatch(). */
  4745. X{
  4746. X  char *p1, *p2;        /* pattern sections */
  4747. X  char *s1, *s2;        /* string sections */
  4748. X  int r;                /* result */
  4749. X
  4750. X  if ((p1 = malloc(strlen(p) + 1)) == NULL ||
  4751. X      (s1 = malloc(strlen(s) + 1)) == NULL)
  4752. X  {
  4753. X    if (p1 != NULL)
  4754. X      free((voidp *)p1);
  4755. X    return 0;
  4756. X  }
  4757. X  strcpy(p1, p);
  4758. X  strcpy(s1, s);
  4759. X  if ((p2 = strrchr(p1, '.')) != NULL)
  4760. X    *p2++ = 0;
  4761. X  else
  4762. X    p2 = "";
  4763. X  if ((s2 = strrchr(s1, '.')) != NULL)
  4764. X    *s2++ = 0;
  4765. X  else
  4766. X    s2 = "";
  4767. X  r = shmatch(p2, s2) && shmatch(p1, s1);
  4768. X  free((voidp *)p1);
  4769. X  free((voidp *)s1);
  4770. X  return r;
  4771. X}
  4772. X#endif /* MSDOS */
  4773. X
  4774. Xvoidp far **search(b, a, n, cmp)
  4775. Xvoidp *b;               /* pointer to value to search for */
  4776. Xvoidp far **a;          /* table of pointers to values, sorted */
  4777. Xextent n;               /* number of pointers in a[] */
  4778. Xint (*cmp) OF((voidp *, voidp far *));  /* comparison function for search */
  4779. X/* Search for b in the pointer list a[0..n-1] using the compare function
  4780. X   cmp(b, c) where c is an element of a[i] and cmp() returns negative if
  4781. X   *b < *c, zero if *b == *c, or positive if *b > *c.  If *b is found,
  4782. X   search returns a pointer to the entry in a[], else search() returns
  4783. X   NULL.  The nature and size of *b and *c (they can be different) are
  4784. X   left up to the cmp() function.  A binary search is used, and it is
  4785. X   assumed that the list is sorted in ascending order. */
  4786. X{
  4787. X  voidp far **i;        /* pointer to midpoint of current range */
  4788. X  voidp far **l;        /* pointer to lower end of current range */
  4789. X  int r;                /* result of (*cmp)() call */
  4790. X  voidp far **u;        /* pointer to upper end of current range */
  4791. X
  4792. X  l = (voidp far **)a;  u = l + (n-1);
  4793. X  while (u >= l)
  4794. X    if ((r = (*cmp)(b, *(i = l + ((u - l) >> 1)))) < 0)
  4795. X      u = i - 1;
  4796. X    else if (r > 0)
  4797. X      l = i + 1;
  4798. X    else
  4799. X      return (voidp far **)i;
  4800. X  return NULL;          /* If b were in list, it would belong at l */
  4801. X}
  4802. X
  4803. X#endif /* !UTIL */
  4804. X
  4805. X
  4806. X/* Table of CRC-32's of all single byte values (made by makecrc.c) */
  4807. Xlocal ulg crctab[] = {
  4808. X  0x00000000L, 0x77073096L, 0xee0e612cL, 0x990951baL, 0x076dc419L,
  4809. X  0x706af48fL, 0xe963a535L, 0x9e6495a3L, 0x0edb8832L, 0x79dcb8a4L,
  4810. X  0xe0d5e91eL, 0x97d2d988L, 0x09b64c2bL, 0x7eb17cbdL, 0xe7b82d07L,
  4811. X  0x90bf1d91L, 0x1db71064L, 0x6ab020f2L, 0xf3b97148L, 0x84be41deL,
  4812. X  0x1adad47dL, 0x6ddde4ebL, 0xf4d4b551L, 0x83d385c7L, 0x136c9856L,
  4813. X  0x646ba8c0L, 0xfd62f97aL, 0x8a65c9ecL, 0x14015c4fL, 0x63066cd9L,
  4814. X  0xfa0f3d63L, 0x8d080df5L, 0x3b6e20c8L, 0x4c69105eL, 0xd56041e4L,
  4815. X  0xa2677172L, 0x3c03e4d1L, 0x4b04d447L, 0xd20d85fdL, 0xa50ab56bL,
  4816. X  0x35b5a8faL, 0x42b2986cL, 0xdbbbc9d6L, 0xacbcf940L, 0x32d86ce3L,
  4817. X  0x45df5c75L, 0xdcd60dcfL, 0xabd13d59L, 0x26d930acL, 0x51de003aL,
  4818. X  0xc8d75180L, 0xbfd06116L, 0x21b4f4b5L, 0x56b3c423L, 0xcfba9599L,
  4819. X  0xb8bda50fL, 0x2802b89eL, 0x5f058808L, 0xc60cd9b2L, 0xb10be924L,
  4820. X  0x2f6f7c87L, 0x58684c11L, 0xc1611dabL, 0xb6662d3dL, 0x76dc4190L,
  4821. X  0x01db7106L, 0x98d220bcL, 0xefd5102aL, 0x71b18589L, 0x06b6b51fL,
  4822. X  0x9fbfe4a5L, 0xe8b8d433L, 0x7807c9a2L, 0x0f00f934L, 0x9609a88eL,
  4823. X  0xe10e9818L, 0x7f6a0dbbL, 0x086d3d2dL, 0x91646c97L, 0xe6635c01L,
  4824. X  0x6b6b51f4L, 0x1c6c6162L, 0x856530d8L, 0xf262004eL, 0x6c0695edL,
  4825. X  0x1b01a57bL, 0x8208f4c1L, 0xf50fc457L, 0x65b0d9c6L, 0x12b7e950L,
  4826. X  0x8bbeb8eaL, 0xfcb9887cL, 0x62dd1ddfL, 0x15da2d49L, 0x8cd37cf3L,
  4827. X  0xfbd44c65L, 0x4db26158L, 0x3ab551ceL, 0xa3bc0074L, 0xd4bb30e2L,
  4828. X  0x4adfa541L, 0x3dd895d7L, 0xa4d1c46dL, 0xd3d6f4fbL, 0x4369e96aL,
  4829. X  0x346ed9fcL, 0xad678846L, 0xda60b8d0L, 0x44042d73L, 0x33031de5L,
  4830. X  0xaa0a4c5fL, 0xdd0d7cc9L, 0x5005713cL, 0x270241aaL, 0xbe0b1010L,
  4831. X  0xc90c2086L, 0x5768b525L, 0x206f85b3L, 0xb966d409L, 0xce61e49fL,
  4832. X  0x5edef90eL, 0x29d9c998L, 0xb0d09822L, 0xc7d7a8b4L, 0x59b33d17L,
  4833. X  0x2eb40d81L, 0xb7bd5c3bL, 0xc0ba6cadL, 0xedb88320L, 0x9abfb3b6L,
  4834. X  0x03b6e20cL, 0x74b1d29aL, 0xead54739L, 0x9dd277afL, 0x04db2615L,
  4835. X  0x73dc1683L, 0xe3630b12L, 0x94643b84L, 0x0d6d6a3eL, 0x7a6a5aa8L,
  4836. X  0xe40ecf0bL, 0x9309ff9dL, 0x0a00ae27L, 0x7d079eb1L, 0xf00f9344L,
  4837. X  0x8708a3d2L, 0x1e01f268L, 0x6906c2feL, 0xf762575dL, 0x806567cbL,
  4838. X  0x196c3671L, 0x6e6b06e7L, 0xfed41b76L, 0x89d32be0L, 0x10da7a5aL,
  4839. X  0x67dd4accL, 0xf9b9df6fL, 0x8ebeeff9L, 0x17b7be43L, 0x60b08ed5L,
  4840. X  0xd6d6a3e8L, 0xa1d1937eL, 0x38d8c2c4L, 0x4fdff252L, 0xd1bb67f1L,
  4841. X  0xa6bc5767L, 0x3fb506ddL, 0x48b2364bL, 0xd80d2bdaL, 0xaf0a1b4cL,
  4842. X  0x36034af6L, 0x41047a60L, 0xdf60efc3L, 0xa867df55L, 0x316e8eefL,
  4843. X  0x4669be79L, 0xcb61b38cL, 0xbc66831aL, 0x256fd2a0L, 0x5268e236L,
  4844. X  0xcc0c7795L, 0xbb0b4703L, 0x220216b9L, 0x5505262fL, 0xc5ba3bbeL,
  4845. X  0xb2bd0b28L, 0x2bb45a92L, 0x5cb36a04L, 0xc2d7ffa7L, 0xb5d0cf31L,
  4846. X  0x2cd99e8bL, 0x5bdeae1dL, 0x9b64c2b0L, 0xec63f226L, 0x756aa39cL,
  4847. X  0x026d930aL, 0x9c0906a9L, 0xeb0e363fL, 0x72076785L, 0x05005713L,
  4848. X  0x95bf4a82L, 0xe2b87a14L, 0x7bb12baeL, 0x0cb61b38L, 0x92d28e9bL,
  4849. X  0xe5d5be0dL, 0x7cdcefb7L, 0x0bdbdf21L, 0x86d3d2d4L, 0xf1d4e242L,
  4850. X  0x68ddb3f8L, 0x1fda836eL, 0x81be16cdL, 0xf6b9265bL, 0x6fb077e1L,
  4851. X  0x18b74777L, 0x88085ae6L, 0xff0f6a70L, 0x66063bcaL, 0x11010b5cL,
  4852. X  0x8f659effL, 0xf862ae69L, 0x616bffd3L, 0x166ccf45L, 0xa00ae278L,
  4853. X  0xd70dd2eeL, 0x4e048354L, 0x3903b3c2L, 0xa7672661L, 0xd06016f7L,
  4854. X  0x4969474dL, 0x3e6e77dbL, 0xaed16a4aL, 0xd9d65adcL, 0x40df0b66L,
  4855. X  0x37d83bf0L, 0xa9bcae53L, 0xdebb9ec5L, 0x47b2cf7fL, 0x30b5ffe9L,
  4856. X  0xbdbdf21cL, 0xcabac28aL, 0x53b39330L, 0x24b4a3a6L, 0xbad03605L,
  4857. X  0xcdd70693L, 0x54de5729L, 0x23d967bfL, 0xb3667a2eL, 0xc4614ab8L,
  4858. X  0x5d681b02L, 0x2a6f2b94L, 0xb40bbe37L, 0xc30c8ea1L, 0x5a05df1bL,
  4859. X  0x2d02ef8dL
  4860. X};
  4861. X
  4862. X
  4863. Xulg crc32(c, b)
  4864. Xulg c;                  /* current contents of crc shift register */
  4865. Xint b;                  /* byte (eight bits) to run through */
  4866. X/* Return the CRC-32 c updated with the eight bits in b. */
  4867. X{
  4868. X  return crctab[((int)c ^ b) & 0xff] ^ (c >> 8);
  4869. X}
  4870. X
  4871. X
  4872. X#ifndef UTIL /* UTIL picks out namecmp code (all utils) and crc32 (zipcloak) */
  4873. X
  4874. Xulg updcrc(s, n)
  4875. Xchar *s;                /* pointer to bytes to pump through */
  4876. Xextent n;               /* number of bytes in s[] */
  4877. X/* Run a set of bytes through the crc shift register.  If s is a NULL
  4878. X   pointer, then initialize the crc shift register contents instead.
  4879. X   Return the current crc in either case. */
  4880. X{
  4881. X  register ulg c;       /* temporary variable */
  4882. X
  4883. X  static ulg crc = 0xffffffffL; /* shift register contents */
  4884. X
  4885. X  if (s == NULL)
  4886. X    c = 0xffffffffL;
  4887. X  else
  4888. X  {
  4889. X    c = crc;
  4890. X    while (n--)
  4891. X      c = crctab[((int)c ^ (*s++)) & 0xff] ^ (c >> 8);
  4892. X  }
  4893. X  crc = c;
  4894. X  return c ^ 0xffffffffL;       /* (instead of ~c for 64-bit machines) */
  4895. X}
  4896. X
  4897. X#endif /* !UTIL */
  4898. X
  4899. X
  4900. X#if (defined(MSDOS) && !defined(OS2) && !defined(__GO32__) && !defined(WIN32))
  4901. X
  4902. Xlocal unsigned ident(unsigned chr)
  4903. X{
  4904. X   return chr; /* in al */
  4905. X}
  4906. X
  4907. Xvoid init_upper()
  4908. X{
  4909. X  static struct country {
  4910. X    uch ignore[18];
  4911. X    int (far *casemap)(int);
  4912. X    uch filler[16];
  4913. X  } country_info;
  4914. X
  4915. X  struct country far *info = &country_info;
  4916. X  union REGS regs;
  4917. X  struct SREGS sregs;
  4918. X  int c;
  4919. X
  4920. X  regs.x.ax = 0x3800; /* get country info */
  4921. X  regs.x.dx = FP_OFF(info);
  4922. X  sregs.ds  = FP_SEG(info);
  4923. X  intdosx(®s, ®s, &sregs);
  4924. X  for (c = 0; c < 128; c++) {
  4925. X    upper[c] = (uch) toupper(c);
  4926. X    lower[c] = (uch) c;
  4927. X  }
  4928. X  for (; c < sizeof(upper); c++) {
  4929. X    upper[c] = (uch) (*country_info.casemap)(ident(c));
  4930. X    /* ident() required because casemap takes its parameter in al */
  4931. X    lower[c] = (uch) c;
  4932. X  }
  4933. X  for (c = 0; c < sizeof(upper); c++ ) {
  4934. X    int u = upper[c];
  4935. X    if (u != c && lower[u] == (uch) u) {
  4936. X      lower[u] = (uch)c;
  4937. X    }
  4938. X  }
  4939. X  for (c = 'A'; c <= 'Z'; c++) {
  4940. X    lower[c] = (uch) (c - 'A' + 'a');
  4941. X  }
  4942. X}
  4943. X#else
  4944. X#  ifndef OS2
  4945. X
  4946. Xvoid init_upper()
  4947. X{
  4948. X  int c;
  4949. X  for (c = 0; c < sizeof(upper); c++) upper[c] = lower[c] = c;
  4950. X  for (c = 'a'; c <= 'z';        c++) upper[c] = c - 'a' + 'A';
  4951. X  for (c = 'A'; c <= 'Z';        c++) lower[c] = c - 'A' + 'a';
  4952. X}
  4953. X#  endif /* OS2 */
  4954. X
  4955. X#endif /* MSDOS && !__GO32__ && !OS2 */
  4956. X
  4957. Xint namecmp(string1, string2)
  4958. X  char *string1, *string2;
  4959. X/* Compare the two strings ignoring case, and correctly taking into
  4960. X * account national language characters. For operating systems with
  4961. X * case sensitive file names, this function is equivalent to strcmp.
  4962. X */
  4963. X{
  4964. X  int d;
  4965. X
  4966. X  for (;;)
  4967. X  {
  4968. X    d = (int) (unsigned char) case_map(*string1)
  4969. X      - (int) (unsigned char) case_map(*string2);
  4970. X    
  4971. X    if (d || *string1 == 0 || *string2 == 0)
  4972. X      return d;
  4973. X      
  4974. X    string1++;
  4975. X    string2++;
  4976. X  }
  4977. X}
  4978. END_OF_FILE
  4979.   if test 12887 -ne `wc -c <'util.c'`; then
  4980.     echo shar: \"'util.c'\" unpacked with wrong size!
  4981.   fi
  4982.   # end of 'util.c'
  4983. fi
  4984. if test -f 'vms/makefile.vms' -a "${1}" != "-c" ; then 
  4985.   echo shar: Will not clobber existing file \"'vms/makefile.vms'\"
  4986. else
  4987.   echo shar: Extracting \"'vms/makefile.vms'\" \(3279 characters\)
  4988.   sed "s/^X//" >'vms/makefile.vms' <<'END_OF_FILE'
  4989. X#============================================================================
  4990. X# Makefile for VMS Zip, ZipCloak, ZipNote  and ZipSplit          Greg Roelofs
  4991. X# Version:  1.8f   [for use with Todd Aven's MAKE/VMS 3.4]       25 June 1992
  4992. X#============================================================================
  4993. X
  4994. X# Most recent revisions:  25 June 1992
  4995. X
  4996. X
  4997. X#####################
  4998. X# MACRO DEFINITIONS #
  4999. X#####################
  5000. X
  5001. XCRYPTO =
  5002. XCLOAK =
  5003. XCFLAGS =
  5004. XUFLAGS = /def=UTIL
  5005. X# Uncomment next three lines for decryption version:
  5006. X#CRYPTO = crypt.obj,
  5007. X#CLOAK = zipcloak.exe
  5008. X#CFLAGS = /def=CRYPT
  5009. X#UFLAGS = /def=(UTIL,CRYPT)
  5010. X
  5011. XCC = cc
  5012. XLIB =
  5013. X# Uncomment next two lines to use the GNU compiler (also add /undef=__STDC__
  5014. X# to CFLAGS and UFLAGS, possibly split UFLAGS into two /def's, and possibly
  5015. X# replace /obj=$@ [below] with copy/rename/delete setup).  NOT TESTED.
  5016. X#CC = gcc
  5017. X#LIB = gnu_cc:[000000]gcclib.olb/lib,
  5018. X
  5019. XE = .exe
  5020. XO = .obj
  5021. XLD = link
  5022. XLDFLAGS =
  5023. X
  5024. XZIPS = zip$E zipnote$E zipsplit$E $(CLOAK)
  5025. X
  5026. X# object file lists
  5027. XOBJZ = zip$O, zipfile$O, zipup$O, fileio$O, $(CRYPTO) util$O,-
  5028. X   globals$O, VMSmunch$O, vms$O
  5029. XOBJI = deflate$O, trees$O, bits$O
  5030. XOBJN = zipnote$O, zipfile_$O, zipup_$O, fileio_$O, util_$O,-
  5031. X   globals$O, VMSmunch$O
  5032. XOBJS = zipsplit$O, zipfile_$O, zipup_$O, fileio_$O, util_$O,-
  5033. X   globals$O, VMSmunch$O
  5034. XOBJC = zipcloak$O, zipfile_$O, zipup_$O, fileio_$O, util$O,-
  5035. X   globals$O, VMSmunch$O, crypt_$O
  5036. X
  5037. X
  5038. X###############################################
  5039. X# BASIC COMPILE INSTRUCTIONS AND DEPENDENCIES #
  5040. X###############################################
  5041. X
  5042. Xdefault:    $(ZIPS)
  5043. X
  5044. X
  5045. X# suffix rules
  5046. X*.obj:    *.c                # `*.c' necessary?
  5047. X    $(CC) $(CFLAGS) $<
  5048. X
  5049. X*_.obj:    *.c                # `$*' not legal
  5050. X    $(CC) $(UFLAGS) /obj=$@ $<
  5051. X
  5052. X
  5053. X# executables makerules (trailing `$' makes line a data line)
  5054. Xzip$E:        $(OBJZ), $(OBJI)
  5055. X    $(LD) $(LDFLAGS) $(OBJZ), $(OBJI), $(LIB) sys$input/opt
  5056. X    sys$share:vaxcrtl.exe/shareable $
  5057. X
  5058. Xzipnote$E:    $(OBJN)
  5059. X    $(LD) $(LDFLAGS) $(OBJN), $(LIB) sys$input/opt
  5060. X    sys$share:vaxcrtl.exe/shareable $
  5061. X
  5062. Xzipcloak$E:    $(OBJC)
  5063. X    $(LD) $(LDFLAGS) $(OBJC), $(LIB) sys$input/opt
  5064. X    sys$share:vaxcrtl.exe/shareable $
  5065. X
  5066. Xzipsplit$E:    $(OBJS)
  5067. X    $(LD) $(LDFLAGS) $(OBJS), $(LIB) sys$input/opt
  5068. X    sys$share:vaxcrtl.exe/shareable $
  5069. X
  5070. X# dependencies for zip, zipnote, zipcloak, and zipsplit
  5071. X$(OBJZ):    zip.h ziperr.h tailor.h
  5072. X$(OBJI):    zip.h ziperr.h tailor.h
  5073. X$(OBJN):    zip.h ziperr.h tailor.h
  5074. X$(OBJS):    zip.h ziperr.h tailor.h
  5075. X$(OBJC):    zip.h ziperr.h tailor.h
  5076. Xfileio$O:    VMSmunch.h
  5077. Xvms$O:          vms.c zip.h
  5078. XVMSmunch$O:     VMSmunch.c VMSmunch.h
  5079. Xzip$O:        revision.h
  5080. Xzipcloak$O:    revision.h
  5081. Xzipfile$O:    VMSmunch.h
  5082. Xzipnote$O:    revision.h
  5083. Xzipsplit$O:    revision.h
  5084. Xzipup$O:    revision.h
  5085. X
  5086. X
  5087. Xclean:
  5088. X    del *.obj;*
  5089. X    del *.exe;*         # use "purge/log" instead?
  5090. X
  5091. X
  5092. X# the backslash '\' is the continuation character if it occurs as
  5093. X# the last non-white character on the line.
  5094. X# the hyphen '-' is the DCL continuation character, so if it occurs
  5095. X# as the last non-white character on the line, the next line will
  5096. X# not have the dollar sign '$' prepended.
  5097. X
  5098. X
  5099. X################################
  5100. X# INDIVIDUAL MACHINE MAKERULES #
  5101. X################################
  5102. X
  5103. Xgeneric:    default        # first try if unknown
  5104. Xgeneric2:    default        # second try if unknown
  5105. Xvax:        default
  5106. Xvms:        default
  5107. X
  5108. Xall:        $(ZIPS)
  5109. Xzip:        zip$E
  5110. Xzipcloak:    zipcloak$E
  5111. Xzipnote:    zipnote$E
  5112. Xzipsplit:    zipsplit$E
  5113. END_OF_FILE
  5114.   if test 3279 -ne `wc -c <'vms/makefile.vms'`; then
  5115.     echo shar: \"'vms/makefile.vms'\" unpacked with wrong size!
  5116.   fi
  5117.   # end of 'vms/makefile.vms'
  5118. fi
  5119. echo shar: End of archive 3 \(of 11\).
  5120. cp /dev/null ark3isdone
  5121. MISSING=""
  5122. for I in 1 2 3 4 5 6 7 8 9 10 11 ; do
  5123.     if test ! -f ark${I}isdone ; then
  5124.     MISSING="${MISSING} ${I}"
  5125.     fi
  5126. done
  5127. if test "${MISSING}" = "" ; then
  5128.     echo You have unpacked all 11 archives.
  5129.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  5130. else
  5131.     echo You still must unpack the following archives:
  5132.     echo "        " ${MISSING}
  5133. fi
  5134. exit 0
  5135. exit 0 # Just in case...
  5136. Newsgroups: comp.sources.misc
  5137. From: zip-bugs@cs.ucla.edu (Info-ZIP group)
  5138. Subject:  v31i096:  zip19 - Info-ZIP portable Zip, version 1.9, Part04/11
  5139. Message-ID: <1992Aug23.064628.29121@sparky.imd.sterling.com>
  5140. X-Md4-Signature: fb99faa1e8171758728591c8da715b75
  5141. Date: Sun, 23 Aug 1992 06:46:28 GMT
  5142. Approved: kent@sparky.imd.sterling.com
  5143.  
  5144. Submitted-by: zip-bugs@cs.ucla.edu (Info-ZIP group)
  5145. Posting-number: Volume 31, Issue 96
  5146. Archive-name: zip19/part04
  5147. Supersedes: zip: Volume 23, Issue 88-96
  5148. Environment: UNIX, VMS, OS/2, MS-DOS, MACINTOSH, WIN-NT, LINUX, MINIX, XOS, !AMIGA, ATARI, symlink, SGI, DEC, Cray, Convex, Amdahl, Sun, PC
  5149.  
  5150. #! /bin/sh
  5151. # This is a shell archive.  Remove anything before this line, then feed it
  5152. # into a shell via "sh file" or similar.  To overwrite existing files,
  5153. # type "sh file -c".
  5154. # The tool that generated this appeared in the comp.sources.unix newsgroup;
  5155. # send mail to comp-sources-unix@uunet.uu.net if you want that tool.
  5156. # Contents:  mac/macstat.h zip.c zip.doc
  5157. # Wrapped by kent@sparky on Sun Aug 23 01:00:44 1992
  5158. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  5159. echo If this archive is complete, you will see the following message:
  5160. echo '          "shar: End of archive 4 (of 11)."'
  5161. if test -f 'mac/macstat.h' -a "${1}" != "-c" ; then 
  5162.   echo shar: Will not clobber existing file \"'mac/macstat.h'\"
  5163. else
  5164.   echo shar: Extracting \"'mac/macstat.h'\" \(974 characters\)
  5165.   sed "s/^X//" >'mac/macstat.h' <<'END_OF_FILE'
  5166. X/*****************************************************************
  5167. X *
  5168. X *                stat.h
  5169. X *
  5170. X *****************************************************************/
  5171. X
  5172. X#include <time.h>
  5173. Xextern int macstat(char *path, struct stat *buf, short nVRefNum, long lDirID );
  5174. Xtypedef long dev_t;
  5175. Xtypedef long ino_t;
  5176. Xtypedef long off_t;
  5177. X
  5178. Xstruct stat {
  5179. X    dev_t    st_dev;
  5180. X    ino_t    st_ino;
  5181. X    unsigned short    st_mode;
  5182. X    short    st_nlink;
  5183. X    short    st_uid;
  5184. X    short    st_gid;
  5185. X    dev_t    st_rdev;
  5186. X    off_t    st_size;
  5187. X    time_t   st_atime, st_mtime, st_ctime;
  5188. X    long     st_blksize;
  5189. X    long     st_blocks;
  5190. X};
  5191. X
  5192. X#define S_IFMT     0xF000
  5193. X#define S_IFIFO    0x1000
  5194. X#define S_IFCHR    0x2000
  5195. X#define S_IFDIR    0x4000
  5196. X#define S_IFBLK    0x6000
  5197. X#define S_IFREG    0x8000
  5198. X#define S_IFLNK    0xA000
  5199. X#define S_IFSOCK   0xC000
  5200. X#define S_ISUID    0x800
  5201. X#define S_ISGID    0x400
  5202. X#define S_ISVTX    0x200
  5203. X#define S_IREAD    0x100
  5204. X#define S_IWRITE   0x80
  5205. X#define S_IEXEC    0x40
  5206. END_OF_FILE
  5207.   if test 974 -ne `wc -c <'mac/macstat.h'`; then
  5208.     echo shar: \"'mac/macstat.h'\" unpacked with wrong size!
  5209.   fi
  5210.   # end of 'mac/macstat.h'
  5211. fi
  5212. if test -f 'zip.c' -a "${1}" != "-c" ; then 
  5213.   echo shar: Will not clobber existing file \"'zip.c'\"
  5214. else
  5215.   echo shar: Extracting \"'zip.c'\" \(32880 characters\)
  5216.   sed "s/^X//" >'zip.c' <<'END_OF_FILE'
  5217. X/*
  5218. X
  5219. X Copyright (C) 1990-1992 Mark Adler, Richard B. Wales, Jean-loup Gailly,
  5220. X Kai Uwe Rommel and Igor Mandrichenko.
  5221. X Permission is granted to any individual or institution to use, copy, or
  5222. X redistribute this software so long as all of the original files are included
  5223. X unmodified, that it is not sold for profit, and that this copyright notice
  5224. X is retained.
  5225. X
  5226. X*/
  5227. X
  5228. X/*
  5229. X *  zip.c by Mark Adler.
  5230. X */
  5231. X
  5232. X#include "revision.h"
  5233. X#include "zip.h"
  5234. X#ifdef VMS
  5235. X#  include "VMSmunch.h"
  5236. X#  define echon() echo(1)
  5237. X#endif
  5238. X#include <signal.h>
  5239. X
  5240. X#ifdef MACOS
  5241. X#  include <console.h>
  5242. X#endif
  5243. X
  5244. X#define PWLEN 80        /* Input buffer size for reading encryption key */
  5245. X#define MAXCOM 256      /* Maximum one-line comment size */
  5246. X
  5247. X
  5248. X/* Local option flags */
  5249. X#define DELETE  0
  5250. X#define ADD     1
  5251. X#define UPDATE  2
  5252. X#define FRESHEN 3
  5253. Xlocal int action = ADD; /* one of ADD, UPDATE, FRESHEN, or DELETE */
  5254. Xlocal int comadd = 0;   /* 1=add comments for new files */
  5255. Xlocal int zipedit = 0;  /* 1=edit zip comment and all file comments */
  5256. Xlocal int dispose = 0;  /* 1=remove files after put in zip file */
  5257. Xlocal int latest = 0;   /* 1=set zip file time to time of latest file */
  5258. Xlocal ulg before = 0;   /* 0=ignore, else exclude files before this time */
  5259. X
  5260. X
  5261. X/* Temporary zip file name and file pointer */
  5262. Xlocal char *tempzip;
  5263. Xlocal FILE *tempzf;
  5264. X
  5265. X
  5266. X/* Local functions */
  5267. X#ifdef PROTO
  5268. X   local void freeup(void);
  5269. X   local void leave(int);
  5270. X   local void handler(int);
  5271. X   local void license(void);
  5272. X   local void help(void);
  5273. X   local void zipstdout(void);
  5274. X   void main(int, char **);
  5275. X   local int count_args(char *s);
  5276. X   local void envargs(int *Pargc, char ***Pargv, char *envstr);
  5277. X#endif /* PROTO */
  5278. X
  5279. X
  5280. X
  5281. Xlocal void freeup()
  5282. X/* Free all allocations in the found list and the zfiles list */
  5283. X{
  5284. X  struct flist far *f;  /* steps through found list */
  5285. X  struct zlist far *z;  /* pointer to next entry in zfiles list */
  5286. X
  5287. X  for (f = found; f != NULL; f = fexpel(f))
  5288. X    ;
  5289. X  while (zfiles != NULL)
  5290. X  {
  5291. X    z = zfiles->nxt;
  5292. X    free((voidp *)(zfiles->name));
  5293. X    free((voidp *)(zfiles->zname));
  5294. X    if (zfiles->ext)
  5295. X      free((voidp *)(zfiles->extra));
  5296. X    if (zfiles->cext && zfiles->cextra != zfiles->extra)
  5297. X      free((voidp *)(zfiles->cextra));
  5298. X    if (zfiles->com)
  5299. X      free((voidp *)(zfiles->comment));
  5300. X    farfree((voidp far *)zfiles);
  5301. X    zfiles = z;
  5302. X    zcount--;
  5303. X  }
  5304. X}
  5305. X
  5306. X
  5307. Xlocal void leave(e)
  5308. Xint e;                  /* exit code */
  5309. X/* Process -o and -m options (if specified), free up malloc'ed stuff, and
  5310. X   exit with the code e. */
  5311. X{
  5312. X  int r;                /* return value from trash() */
  5313. X  ulg t;                /* latest time in zip file */
  5314. X  struct zlist far *z;  /* pointer into zfile list */
  5315. X
  5316. X  /* If latest, set time to zip file to latest file in zip file */
  5317. X  if (latest && strcmp(zipfile, "-"))
  5318. X  {
  5319. X    diag("changing time of zip file to time of latest file in it");
  5320. X    /* find latest time in zip file */
  5321. X    if (zfiles == NULL)
  5322. X       warn("zip file is empty, can't make it as old as latest entry", "");
  5323. X    else {
  5324. X      t = zfiles->tim;
  5325. X      for (z = zfiles->nxt; z != NULL; z = z->nxt)
  5326. X        if (t < z->tim)
  5327. X          t = z->tim;
  5328. X      /* set modified time of zip file to that time */
  5329. X      stamp(zipfile, t);
  5330. X    }
  5331. X  }
  5332. X  if (tempath != NULL)
  5333. X  {
  5334. X    free((voidp *)tempath);
  5335. X    tempath = NULL;
  5336. X  }
  5337. X  if (zipfile != NULL)
  5338. X  {
  5339. X    free((voidp *)zipfile);
  5340. X    zipfile = NULL;
  5341. X  }
  5342. X
  5343. X
  5344. X  /* If dispose, delete all files in the zfiles list that are marked */
  5345. X  if (dispose)
  5346. X  {
  5347. X    diag("deleting files that were added to zip file");
  5348. X    if ((r = trash()) != ZE_OK)
  5349. X      err(r, "was deleting moved files and directories");
  5350. X  }
  5351. X
  5352. X
  5353. X  /* Done! */
  5354. X  freeup();
  5355. X#ifdef VMS
  5356. X  exit(0);
  5357. X#else /* !VMS */
  5358. X  exit(e);
  5359. X#endif /* ?VMS */
  5360. X}
  5361. X
  5362. X
  5363. Xvoid err(c, h)
  5364. Xint c;                  /* error code from the ZE_ class */
  5365. Xchar *h;                /* message about how it happened */
  5366. X/* Issue a message for the error, clean up files and memory, and exit. */
  5367. X{
  5368. X  static int error_level;
  5369. X  if (error_level++ > 0) exit(0);  /* avoid recursive err() */
  5370. X
  5371. X  if (PERR(c))
  5372. X    perror("zip error");
  5373. X  fprintf(stderr, "zip error: %s (%s)\n", errors[c-1], h);
  5374. X  if (tempzip != NULL)
  5375. X  {
  5376. X    if (tempzip != zipfile) {
  5377. X      if (tempzf != NULL)
  5378. X        fclose(tempzf);
  5379. X#ifndef DEBUG
  5380. X      destroy(tempzip);
  5381. X#endif
  5382. X      free((voidp *)tempzip);
  5383. X    } else {
  5384. X      /* -g option, attempt to restore the old file */
  5385. X      int k = 0;                        /* keep count for end header */
  5386. X      ulg cb = cenbeg;                  /* get start of central */
  5387. X      struct zlist far *z;  /* steps through zfiles linked list */
  5388. X
  5389. X      fprintf(stderr, "attempting to restore %s to its previous state\n",
  5390. X         zipfile);
  5391. X      fseek(tempzf, cenbeg, SEEK_SET);
  5392. X      tempzn = cenbeg;
  5393. X      for (z = zfiles; z != NULL; z = z->nxt)
  5394. X      {
  5395. X        putcentral(z, tempzf);
  5396. X        tempzn += 4 + CENHEAD + z->nam + z->cext + z->com;
  5397. X        k++;
  5398. X      }
  5399. X      putend(k, tempzn - cb, cb, zcomlen, zcomment, tempzf);
  5400. X      tempzf = NULL;
  5401. X      fclose(tempzf);
  5402. X    }
  5403. X  }
  5404. X  if (key != NULL)
  5405. X    free((voidp *)key);
  5406. X  if (tempath != NULL)
  5407. X    free((voidp *)tempath);
  5408. X  if (zipfile != NULL)
  5409. X    free((voidp *)zipfile);
  5410. X  freeup();
  5411. X#ifdef VMS
  5412. X  c = 0;
  5413. X#endif
  5414. X  exit(c);
  5415. X}
  5416. X
  5417. X
  5418. Xvoid error(h)
  5419. X  char *h;
  5420. X/* Internal error, should never happen */
  5421. X{
  5422. X  err(ZE_LOGIC, h);
  5423. X}
  5424. X
  5425. Xlocal void handler(s)
  5426. Xint s;                  /* signal number (ignored) */
  5427. X/* Upon getting a user interrupt, turn echo back on for tty and abort
  5428. X   cleanly using err(). */
  5429. X{
  5430. X#ifndef MSDOS
  5431. X# ifdef CRYPT
  5432. X   echon();
  5433. X# endif
  5434. X  putc('\n', stderr);
  5435. X#endif /* !MSDOS */
  5436. X  err(ZE_ABORT, "aborting");
  5437. X  s++;                                  /* keep some compilers happy */
  5438. X}
  5439. X
  5440. X
  5441. Xvoid warn(a, b)
  5442. Xchar *a, *b;            /* message strings juxtaposed in output */
  5443. X/* Print a warning message to stderr and return. */
  5444. X{
  5445. X  fprintf(stderr, "zip warning: %s%s\n", a, b);
  5446. X}
  5447. X
  5448. X
  5449. Xlocal void license()
  5450. X/* Print license information to stdout. */
  5451. X{
  5452. X  extent i;             /* counter for copyright array */
  5453. X
  5454. X  for (i = 0; i < sizeof(copyright)/sizeof(char *); i++) {
  5455. X    printf(copyright[i], "zip");
  5456. X    putchar('\n');
  5457. X  }
  5458. X  for (i = 0; i < sizeof(disclaimer)/sizeof(char *); i++)
  5459. X    puts(disclaimer[i]);
  5460. X}
  5461. X
  5462. X
  5463. Xlocal void help()
  5464. X/* Print help (along with license info) to stdout. */
  5465. X{
  5466. X  extent i;             /* counter for help array */
  5467. X
  5468. X  /* help array */
  5469. X  static char *text[] = {
  5470. X"",
  5471. X"Zip %d.%d (%s). Usage:",
  5472. X"zip [-options] [-b path] [-t mmddyy] [-n suffixes] [zipfile list] [-x list]",
  5473. X"  The default action is to add or replace zipfile entries from list, which",
  5474. X"  can include the special name - to compress standard input.",
  5475. X"  If zipfile and list are ommitted, zip compresses stdin to stdout.",
  5476. X"  -f   freshen: only changed files  -u   update: only changed or new files",
  5477. X"  -d   delete entries in zipfile    -m   move into zipfile (delete files)",
  5478. X"  -k   simulate PKZIP made zipfile  -g   allow growing existing zipfile",
  5479. X"  -h   show this help               -L   show software license",
  5480. X"  -r   recurse into directories     -j   junk (don't record) directory names",
  5481. X"  -0   store only                   -l   translate end-of-line",
  5482. X"  -1   compress faster              -9   compress better",
  5483. X"  -q   quiet operation              -n   don't compress these suffixes",
  5484. X"  -c   add one-line comments        -z   add zipfile comment",
  5485. X"  -b   use \"path\" for temp files    -t   only do files after \"mmddyy\"",
  5486. X"  -@   read names from stdin        -o   make zipfile as old as latest entry",
  5487. X#ifdef CRYPT
  5488. X"  -e   encrypt  (-ee verify key)",
  5489. X#endif
  5490. X#ifdef VMS
  5491. X"  -w   append the VMS version number to the name stored in the zip file",
  5492. X"  -V   save VMS file attributes",
  5493. X#endif /* VMS */
  5494. X#ifdef OS2
  5495. X"  -E   use the .LONGNAME Extended attribute (if found) as filename",
  5496. X#endif /* OS2 */
  5497. X#ifdef S_IFLNK
  5498. X"  -y   store symbolic links as the link instead of the referenced file",
  5499. X#endif /* !S_IFLNK */
  5500. X"  -x   exclude the names that follow from those operated on"
  5501. X  };
  5502. X
  5503. X  for (i = 0; i < sizeof(copyright)/sizeof(char *); i++)
  5504. X  {
  5505. X    printf(copyright[i], "zip");
  5506. X    putchar('\n');
  5507. X  }
  5508. X  for (i = 0; i < sizeof(text)/sizeof(char *); i++)
  5509. X  {
  5510. X    printf(text[i], REVISION / 10, REVISION % 10, REVDATE);
  5511. X    putchar('\n');
  5512. X  }
  5513. X}
  5514. X
  5515. X
  5516. X/* Do command line expansion for MSDOS and VMS */
  5517. X#if defined(MSVMS) && !defined(__GO32__)
  5518. X#  define PROCNAME(n) (action==ADD||action==UPDATE?wild(n):procname(n))
  5519. X#else /* !MSVMS */
  5520. X#  define PROCNAME(n) procname(n)
  5521. X#endif /* ?MSVMS */
  5522. X
  5523. Xlocal void zipstdout()
  5524. X/* setup for writing zip file on stdout */
  5525. X{
  5526. X  int r;
  5527. X  mesg = stderr;
  5528. X  if (isatty(1))
  5529. X    err(ZE_PARMS, "no zip file provided");
  5530. X  if ((zipfile = malloc(4)) == NULL)
  5531. X    err(ZE_MEM, "was processing arguments");
  5532. X  strcpy(zipfile, "-");
  5533. X  if ((r = readzipfile()) != ZE_OK)
  5534. X    err(r, zipfile);
  5535. X}
  5536. X
  5537. X
  5538. Xvoid main(argc, argv)
  5539. Xint argc;               /* number of tokens in command line */
  5540. Xchar **argv;            /* command line tokens */
  5541. X/* Add, update, freshen, or delete zip entries in a zip file.  See the
  5542. X   command help in help() above. */
  5543. X{
  5544. X  int a;                /* attributes of zip file */
  5545. X  ulg c;                /* start of central directory */
  5546. X  int d;                /* true if just adding to a zip file */
  5547. X  char *e;              /* malloc'd comment buffer */
  5548. X  struct flist far *f;  /* steps through found linked list */
  5549. X  int i;                /* arg counter, root directory flag */
  5550. X  int k;                /* next argument type, marked counter,
  5551. X                           comment size, entry count */
  5552. X  ulg n;                /* total of entry len's */
  5553. X  int o;                /* true if there were any ZE_OPEN errors */
  5554. X  char *p;              /* steps through option arguments */
  5555. X  char *pp;             /* temporary pointer */
  5556. X  int r;                /* temporary variable */
  5557. X  ulg t;                /* file time, length of central directory */
  5558. X  struct zlist far *v;  /* temporary variable */
  5559. X  struct zlist far * far *w;    /* pointer to last link in zfiles list */
  5560. X  FILE *x, *y;          /* input and output zip files */
  5561. X  struct zlist far *z;  /* steps through zfiles linked list */
  5562. X  char *zipbuf;         /* stdio buffer for the zip file */
  5563. X
  5564. X  mesg = (FILE *) stdout; /* cannot be made at link time for VMS */
  5565. X  init_upper();           /* build case map table */
  5566. X
  5567. X#ifdef MACOS
  5568. X   argc = ccommand(&argv);
  5569. X#endif
  5570. X
  5571. X  /* Process arguments */
  5572. X  diag("processing arguments");
  5573. X  if (argc == 1 && isatty(1))
  5574. X  {
  5575. X    help();
  5576. X    exit(0);
  5577. X  }
  5578. X  envargs(&argc, &argv, "ZIPOPT"); /* get options from environment */
  5579. X
  5580. X  zipfile = tempzip = NULL;
  5581. X  tempzf = NULL;
  5582. X  d = 0;                        /* disallow adding to a zip file */
  5583. X  signal(SIGINT, handler);
  5584. X  signal(SIGTERM, handler);
  5585. X  k = 0;                        /* Next non-option argument type */
  5586. X  for (i = 1; i < argc; i++)
  5587. X  {
  5588. X    if (argv[i][0] == '-')
  5589. X      if (argv[i][1])
  5590. X        for (p = argv[i]+1; *p; p++)
  5591. X          switch(*p)
  5592. X          {
  5593. X            case '0':
  5594. X              method = STORE; level = 0; break;
  5595. X            case '1':  case '2':  case '3':  case '4':
  5596. X            case '5':  case '6':  case '7':  case '8':  case '9':
  5597. X                        /* Set the compression efficacy */
  5598. X              level = *p - '0';  break;
  5599. X            case 'b':   /* Specify path for temporary file */
  5600. X              if (k != 0)
  5601. X                err(ZE_PARMS, "use -b before zip file name");
  5602. X              else
  5603. X                k = 1;          /* Next non-option is path */
  5604. X              break;
  5605. X            case 'c':   /* Add comments for new files in zip file */
  5606. X              comadd = 1;  break;
  5607. X            case 'd':   /* Delete files from zip file */
  5608. X              if (action != ADD)
  5609. X                err(ZE_PARMS, "specify just one action");
  5610. X              action = DELETE;
  5611. X              break;
  5612. X#ifdef CRYPT
  5613. X            case 'e':   /* Encrypt */
  5614. X              e = key == NULL ? (char *)NULL : key;
  5615. X              if ((key = malloc(PWLEN+1)) == NULL)
  5616. X                err(ZE_MEM, "was getting encryption password");
  5617. X              if (getp(e == NULL ? "Enter password: " : "Verify password: ",
  5618. X                       key, PWLEN+1) == NULL)
  5619. X                err(ZE_PARMS, "stderr is not a tty");
  5620. X              if (e != NULL)
  5621. X              {
  5622. X                r = strcmp(key, e);
  5623. X                free((voidp *)e);
  5624. X                if (r)
  5625. X                  err(ZE_PARMS, "password not verified");
  5626. X              }
  5627. X              latest = 1;               /* to make breaking the code harder */
  5628. X              break;
  5629. X#endif /* CRYPT */
  5630. X            case 'f':   /* Freshen zip file--overwrite only */
  5631. X              if (action != ADD)
  5632. X                err(ZE_PARMS, "specify just one action");
  5633. X              action = FRESHEN;
  5634. X              break;
  5635. X            case 'g':   /* Allow appending to a zip file */
  5636. X              d = 1;  break;
  5637. X            case 'h': case 'H': case '?':  /* Help */
  5638. X              help();
  5639. X              leave(ZE_OK);
  5640. X            case 'j':   /* Junk directory names */
  5641. X              pathput = 0;  break;
  5642. X            case 'k':   /* Make entries using DOS names (k for Katz) */
  5643. X              dosify = 1;  break;
  5644. X            case 'l':   /* Translate end-of-line */
  5645. X              translate_eol = 1; break;
  5646. X            case 'L':   /* Show license, version */
  5647. X              license();
  5648. X              leave(ZE_OK);
  5649. X            case 'm':   /* Delete files added or updated in zip file */
  5650. X              dispose = 1;  break;
  5651. X            case 'n':   /* Don't compress files with a special suffix */
  5652. X              special = NULL;
  5653. X              break;
  5654. X            case 'o':   /* Set zip file time to time of latest file in it */
  5655. X              latest = 1;  break;
  5656. X            case 'p':   /* Store path with name */
  5657. X              break;            /* (do nothing as annoyance avoidance) */
  5658. X            case 'q':   /* Quiet operation */
  5659. X              noisy = 0;  break;
  5660. X            case 'r':   /* Recurse into subdirectories */
  5661. X              recurse = 1;  break;
  5662. X            case 't':   /* Exclude files earlier than specified date */
  5663. X              if (before)
  5664. X                err(ZE_PARMS, "can only have one -t");
  5665. X              k = 2;  break;
  5666. X            case 'u':   /* Update zip file--overwrite only if newer */
  5667. X              if (action != ADD)
  5668. X                err(ZE_PARMS, "specify just one action");
  5669. X              action = UPDATE;
  5670. X              break;
  5671. X            case 'v':   /* Mention oddities in zip file structure */
  5672. X              verbose++;
  5673. X              break;
  5674. X#ifdef VMS
  5675. X            case 'w':   /* Append the VMS version number */
  5676. X              vmsver = 1;  break;
  5677. X            case 'V':   /* Store in VMS format */
  5678. X              vms_native = 1; break;
  5679. X#endif /* VMS */
  5680. X            case 'x':   /* Exclude following files */
  5681. X              if (k != 4 &&
  5682. X                  (k != 3 || (action != UPDATE && action != FRESHEN)))
  5683. X                err(ZE_PARMS, "nothing to exclude (-x) from");
  5684. X              if (k == 3)       /* must be -u or -f */
  5685. X                for (z = zfiles; z != NULL; z = z->nxt)
  5686. X                  z->mark = 1;  /* mark all of them */
  5687. X              k = 5;
  5688. X              if ((r = exclude()) != ZE_OK)
  5689. X                if (r == ZE_PARMS)
  5690. X                  err(r, "cannot repeat names in zip file");
  5691. X                else
  5692. X                  err(r, "was processing list of files");
  5693. X              break;
  5694. X#ifdef S_IFLNK
  5695. X            case 'y':   /* Store symbolic links as such */
  5696. X              linkput = 1;  break;
  5697. X#endif /* S_IFLNK */
  5698. X            case 'z':   /* Edit zip file comment */
  5699. X              zipedit = 1;  break;
  5700. X            case '@':   /* read file names from stdin */
  5701. X              while ((pp = getnam(errbuf)) != NULL)
  5702. X              {
  5703. X                if ((r = PROCNAME(pp)) != ZE_OK)
  5704. X                  if (r == ZE_MISS)
  5705. X                    warn("name not matched: ", pp);
  5706. X                  else
  5707. X                    err(r, pp);
  5708. X              }
  5709. X              break;
  5710. X#ifdef OS2
  5711. X            case 'E':
  5712. X              /* use the .LONGNAME EA (if any) as the file's name. */
  5713. X              use_longname_ea = 1;
  5714. X              break;
  5715. X#endif
  5716. X            default:
  5717. X            {
  5718. X              sprintf(errbuf, "no such option: %c", *p);
  5719. X              err(ZE_PARMS, errbuf);
  5720. X            }
  5721. X          }
  5722. X      else              /* just a dash */
  5723. X        switch (k)
  5724. X        {
  5725. X        case 0:
  5726. X          zipstdout();
  5727. X          k = 3;
  5728. X          break;
  5729. X        case 1:
  5730. X          err(ZE_PARMS, "invalid path");
  5731. X          break;
  5732. X        case 2:
  5733. X          err(ZE_PARMS, "invalid time");
  5734. X          break;
  5735. X        case 3:  case 4:  case 5:
  5736. X          if ((r = PROCNAME(argv[i])) != ZE_OK)
  5737. X            if (r == ZE_MISS)
  5738. X              warn("name not matched: ", argv[i]);
  5739. X            else
  5740. X              err(r, argv[i]);
  5741. X          if (k == 3)
  5742. X            k = 4;
  5743. X        }
  5744. X    else                /* not an option */
  5745. X    {
  5746. X      if (special == NULL)
  5747. X        special = argv[i];
  5748. X      else
  5749. X        switch (k)
  5750. X      {
  5751. X        case 0:
  5752. X          if ((zipfile = ziptyp(argv[i])) == NULL)
  5753. X            err(ZE_MEM, "was processing arguments");
  5754. X          if ((r = readzipfile()) != ZE_OK)
  5755. X            err(r, zipfile);
  5756. X          k = 3;
  5757. X          break;
  5758. X        case 1:
  5759. X          if ((tempath = malloc(strlen(argv[i]) + 1)) == NULL)
  5760. X            err(ZE_MEM, "was processing arguments");
  5761. X          strcpy(tempath, argv[i]);
  5762. X          k = 0;
  5763. X          break;
  5764. X        case 2:
  5765. X        {
  5766. X          int yy, mm, dd;       /* results of sscanf() */
  5767. X
  5768. X          if (sscanf(argv[i], "%2d%2d%2d", &mm, &dd, &yy) != 3 ||
  5769. X              mm < 1 || mm > 12 || dd < 1 || dd > 31)
  5770. X            err(ZE_PARMS, "invalid date entered for -t option");
  5771. X          before = dostime(yy + (yy < 80 ? 2000 : 1900), mm, dd, 0, 0, 0);
  5772. X          k = 0;
  5773. X          break;
  5774. X        }
  5775. X        case 3:  case 4:  case 5:
  5776. X          if ((r = PROCNAME(argv[i])) != ZE_OK)
  5777. X            if (r == ZE_MISS)
  5778. X              warn("name not matched: ", argv[i]);
  5779. X            else
  5780. X              err(r, argv[i]);
  5781. X          if (k == 3)
  5782. X            k = 4;
  5783. X      }
  5784. X    }
  5785. X  }
  5786. X  if (k < 3) {               /* zip used as filter */
  5787. X    zipstdout();
  5788. X    if ((r = procname("-")) != ZE_OK)
  5789. X      if (r == ZE_MISS)
  5790. X        warn("name not matched: ", "-");
  5791. X      else
  5792. X        err(r, "-");
  5793. X    k = 4;
  5794. X  }
  5795. X
  5796. X  if (k != 5)                   /* Clean up selections */
  5797. X  {
  5798. X    if (k == 3 && (action == UPDATE || action == FRESHEN))
  5799. X      for (z = zfiles; z != NULL; z = z->nxt)
  5800. X        z->mark = 1;                    /* if -u or -f with no args, do all */
  5801. X    if ((r = exclude()) != ZE_OK)       /* remove duplicates in found list */
  5802. X      if (r == ZE_PARMS)
  5803. X        err(r, "cannot repeat names in zip file");
  5804. X      else
  5805. X        err(r, "was processing list of files");
  5806. X  }
  5807. X  if (zcount)
  5808. X    free((voidp *)zsort);
  5809. X
  5810. X  /* Check option combinations */
  5811. X  if (action == DELETE && (method != BEST || dispose || recurse ||
  5812. X      key != NULL || comadd || zipedit))
  5813. X    err(ZE_PARMS, "invalid option(s) used with -d");
  5814. X  if (linkput && dosify)
  5815. X    err(ZE_PARMS, "can't use -y with -k");
  5816. X  if ((action != ADD || d) && !strcmp(zipfile, "-"))
  5817. X    err(ZE_PARMS, "can't use -d,-f,-u or -g on standard output");
  5818. X#ifdef VMS
  5819. X  if (vms_native && translate_eol)
  5820. X    err(ZE_PARMS, "can't use -V with -l");
  5821. X#endif
  5822. X  if (zcount == 0 && (action != ADD || d))
  5823. X    warn(zipfile, " not found or empty");
  5824. X
  5825. X
  5826. X  /* If -b not specified, make temporary path the same as the zip file */
  5827. X#ifdef MSDOS
  5828. X  if (tempath == NULL && ((p = strrchr(zipfile, '/')) != NULL ||
  5829. X                          (p = strrchr(zipfile, '\\')) != NULL ||
  5830. X                          (p = strrchr(zipfile, ':')) != NULL))
  5831. X  {
  5832. X    if (*p == ':')
  5833. X      p++;
  5834. X#else /* !MSDOS */
  5835. X  if (tempath == NULL && (p = strrchr(zipfile, '/')) != NULL)
  5836. X  {
  5837. X#endif /* ?MSDOS */
  5838. X    if ((tempath = malloc((int)(p - zipfile) + 1)) == NULL)
  5839. X      err(ZE_MEM, "was processing arguments");
  5840. X    r = *p;  *p = 0;
  5841. X    strcpy(tempath, zipfile);
  5842. X    *p = (char)r;
  5843. X  }
  5844. X
  5845. X  /* For each marked entry, if not deleting, check if it exists, and if
  5846. X     updating or freshening, compare date with entry in old zip file.
  5847. X     Unmark if it doesn't exist or is too old, else update marked count. */
  5848. X  diag("stating marked entries");
  5849. X  k = 0;                        /* Initialize marked count */
  5850. X  for (z = zfiles; z != NULL; z = z->nxt)
  5851. X    if (z->mark)
  5852. X      if (action != DELETE &&
  5853. X                ((t = filetime(z->name, (ulg *)NULL, (long *)NULL)) == 0 ||
  5854. X                 t < before ||
  5855. X                 ((action == UPDATE || action == FRESHEN) && t <= z->tim)))
  5856. X      {
  5857. X        z->mark = 0;
  5858. X        z->trash = t && t >= before;    /* delete if -um or -fm */
  5859. X        if (verbose)
  5860. X          fprintf(mesg, "zip diagnostic: %s %s\n", z->name,
  5861. X                 z->trash ? "up to date" : "missing or early");
  5862. X      }
  5863. X      else
  5864. X        k++;
  5865. X
  5866. X
  5867. X  /* Remove entries from found list that do not exist or are too old */
  5868. X  diag("stating new entries");
  5869. X  for (f = found; f != NULL;)
  5870. X    if (action == DELETE || action == FRESHEN ||
  5871. X        (t = filetime(f->name, (ulg *)NULL, (long *)NULL)) == 0 ||
  5872. X        t < before || (namecmp(f->name, zipfile) == 0 && strcmp(zipfile, "-")))
  5873. X      f = fexpel(f);
  5874. X    else
  5875. X      f = f->nxt;
  5876. X
  5877. X  /* Make sure there's something left to do */
  5878. X  if (k == 0 && found == NULL && !(zfiles != NULL && (latest || zipedit)))
  5879. X    if (action == UPDATE || action == FRESHEN)
  5880. X      leave(ZE_OK);
  5881. X    else if (zfiles == NULL && latest)
  5882. X      err(ZE_NAME, zipfile);
  5883. X    else
  5884. X      err(ZE_NONE, zipfile);
  5885. X  d = (d && k == 0 && (zipbeg || zfiles != NULL)); /* d true if appending */
  5886. X
  5887. X
  5888. X  /* Before we get carried away, make sure zip file is writeable */
  5889. X  if (strcmp(zipfile, "-"))
  5890. X  {
  5891. X    x = zfiles == NULL && zipbeg == 0 ? fopen(zipfile, FOPW) : 
  5892. X                                        fopen(zipfile, FOPM);
  5893. X    /* Note: FOPW and FOPM expand to several parameters for VMS */
  5894. X    if (x == NULL)
  5895. X      err(ZE_CREAT, zipfile);
  5896. X    fclose(x);
  5897. X    a = getfileattr(zipfile);
  5898. X    if (zfiles == NULL && zipbeg == 0)
  5899. X      destroy(zipfile);
  5900. X  }
  5901. X  else
  5902. X    a = 0;
  5903. X
  5904. X
  5905. X  /* Open zip file and temporary output file */
  5906. X  diag("opening zip file and creating temporary zip file");
  5907. X  x = NULL;
  5908. X  tempzn = 0;
  5909. X  if (strcmp(zipfile, "-") == 0)
  5910. X  {
  5911. X#ifdef MSDOS
  5912. X    /* Set stdout mode to binary for MSDOS systems */
  5913. X    setmode(fileno(stdout), O_BINARY);
  5914. X    tempzf = y = fdopen(fileno(stdout), FOPW);
  5915. X#else
  5916. X    tempzf = y = stdout;
  5917. X#endif
  5918. X    tempzip = "-";
  5919. X  }
  5920. X  else if (d) /* d true if just appending (-g) */
  5921. X  {
  5922. X    if ((y = fopen(zipfile, FOPM)) == NULL)
  5923. X      err(ZE_NAME, zipfile);
  5924. X    tempzip = zipfile;
  5925. X    tempzf = y;
  5926. X    if (fseek(y, cenbeg, SEEK_SET))
  5927. X      err(ferror(y) ? ZE_READ : ZE_EOF, zipfile);
  5928. X    tempzn = cenbeg;
  5929. X  }
  5930. X  else
  5931. X  {
  5932. X    if ((zfiles != NULL || zipbeg) && (x = fopen(zipfile, FOPR_EX)) == NULL)
  5933. X      err(ZE_NAME, zipfile);
  5934. X    if ((tempzip = tempname(zipfile)) == NULL)
  5935. X      err(ZE_MEM, tempzip);
  5936. X    if ((tempzf = y = fopen(tempzip, FOPW)) == NULL)
  5937. X      err(ZE_TEMP, tempzip);
  5938. X    if (zipbeg && (r = fcopy(x, y, zipbeg)) != ZE_OK)
  5939. X      err(r, r == ZE_TEMP ? tempzip : zipfile);
  5940. X    tempzn = zipbeg;
  5941. X  }
  5942. X#ifndef VMS
  5943. X  /* Use large buffer to speed up stdio: */
  5944. X  zipbuf = (char *)malloc(ZBSZ);
  5945. X  if (zipbuf == NULL)
  5946. X    err(ZE_MEM, tempzip);
  5947. X# ifdef _IOFBF
  5948. X  setvbuf(y, zipbuf, _IOFBF, ZBSZ);
  5949. X# else
  5950. X  setbuf(y, zipbuf);
  5951. X# endif /* _IOBUF */
  5952. X#endif /* VMS */
  5953. X  o = 0;                                /* no ZE_OPEN errors yet */
  5954. X
  5955. X
  5956. X  /* Process zip file, updating marked files */
  5957. X  if (zfiles != NULL)
  5958. X    diag("going through old zip file");
  5959. X  w = &zfiles;
  5960. X  while ((z = *w) != NULL)
  5961. X    if (z->mark)
  5962. X    {
  5963. X      /* if not deleting, zip it up */
  5964. X      if (action != DELETE)
  5965. X      {
  5966. X        if (noisy)
  5967. X        {
  5968. X          fprintf(mesg, "updating %s", z->zname);
  5969. X          fflush(mesg);
  5970. X        }
  5971. X        if ((r = zipup(z, y)) != ZE_OK && r != ZE_OPEN)
  5972. X        {
  5973. X          if (noisy)
  5974. X          {
  5975. X            putc('\n', mesg);
  5976. X            fflush(mesg);
  5977. X          }
  5978. X          sprintf(errbuf, "was zipping %s", z->name);
  5979. X          err(r, errbuf);
  5980. X        }
  5981. X        if (r == ZE_OPEN)
  5982. X        {
  5983. X          o = 1;
  5984. X          if (noisy)
  5985. X          {
  5986. X            putc('\n', mesg);
  5987. X            fflush(mesg);
  5988. X          }
  5989. X          perror("zip warning");
  5990. X          warn("could not open for reading: ", z->name);
  5991. X          warn("will just copy entry over: ", z->zname);
  5992. X          if ((r = zipcopy(z, x, y)) != ZE_OK)
  5993. X          {
  5994. X            sprintf(errbuf, "was copying %s", z->zname);
  5995. X            err(r, errbuf);
  5996. X          }
  5997. X          z->mark = 0;
  5998. X        }
  5999. X        w = &z->nxt;
  6000. X      }
  6001. X      else
  6002. X      {
  6003. X        if (noisy)
  6004. X        {
  6005. X          fprintf(mesg, "deleting %s\n", z->zname);
  6006. X          fflush(mesg);
  6007. X        }
  6008. X        v = z->nxt;                     /* delete entry from list */
  6009. X        free((voidp *)(z->name));
  6010. X        free((voidp *)(z->zname));
  6011. X        if (z->ext)
  6012. X          free((voidp *)(z->extra));
  6013. X        if (z->cext && z->cextra != z->extra)
  6014. X          free((voidp *)(z->cextra));
  6015. X        if (z->com)
  6016. X          free((voidp *)(z->comment));
  6017. X        farfree((voidp far *)z);
  6018. X        *w = v;
  6019. X        zcount--;
  6020. X      }
  6021. X    }
  6022. X    else
  6023. X    {
  6024. X      /* copy the original entry verbatim */
  6025. X      if (!d && (r = zipcopy(z, x, y)) != ZE_OK)
  6026. X      {
  6027. X        sprintf(errbuf, "was copying %s", z->zname);
  6028. X        err(r, errbuf);
  6029. X      }
  6030. X      w = &z->nxt;
  6031. X    }
  6032. X
  6033. X
  6034. X  /* Process the edited found list, adding them to the zip file */
  6035. X  diag("zipping up new entries, if any");
  6036. X  for (f = found; f != NULL; f = fexpel(f))
  6037. X  {
  6038. X    /* add a new zfiles entry and set the name */
  6039. X    if ((z = (struct zlist far *)farmalloc(sizeof(struct zlist))) == NULL)
  6040. X      err(ZE_MEM, "was adding files to zip file");
  6041. X    z->nxt = NULL;
  6042. X    z->name = f->name;
  6043. X    f->name = NULL;
  6044. X    z->zname = f->zname;
  6045. X    f->zname = NULL;
  6046. X    z->ext = z->cext = z->com = 0;
  6047. X    z->mark = 1;
  6048. X    z->dosflag = f->dosflag;
  6049. X    /* zip it up */
  6050. X    if (noisy)
  6051. X    {
  6052. X      fprintf(mesg, "adding %s", z->zname);
  6053. X      fflush(mesg);
  6054. X    }
  6055. X    if ((r = zipup(z, y)) != ZE_OK  && r != ZE_OPEN)
  6056. X    {
  6057. X      if (noisy)
  6058. X      {
  6059. X        putc('\n', mesg);
  6060. X        fflush(mesg);
  6061. X      }
  6062. X      sprintf(errbuf, "was zipping %s", z->name);
  6063. X      err(r, errbuf);
  6064. X    }
  6065. X    if (r == ZE_OPEN)
  6066. X    {
  6067. X      o = 1;
  6068. X      if (noisy)
  6069. X      {
  6070. X        putc('\n', mesg);
  6071. X        fflush(mesg);
  6072. X      }
  6073. X      perror("zip warning");
  6074. X      warn("could not open for reading: ", z->name);
  6075. X      free((voidp *)(z->name));
  6076. X      free((voidp *)(z->zname));
  6077. X      farfree((voidp far *)z);
  6078. X    }
  6079. X    else
  6080. X    {
  6081. X      *w = z;
  6082. X      w = &z->nxt;
  6083. X      zcount++;
  6084. X    }
  6085. X  }
  6086. X  if (key != NULL)
  6087. X  {
  6088. X    free((voidp *)key);
  6089. X    key = NULL;
  6090. X  }
  6091. X
  6092. X
  6093. X  /* Get one line comment for each new entry */
  6094. X  if (comadd)
  6095. X  {
  6096. X    if ((e = malloc(MAXCOM + 1)) == NULL)
  6097. X      err(ZE_MEM, "was reading comment lines");
  6098. X    for (z = zfiles; z != NULL; z = z->nxt)
  6099. X      if (z->mark)
  6100. X      {
  6101. X        if (noisy)
  6102. X          fprintf(mesg, "Enter comment for %s:\n", z->name);
  6103. X        /* ??? reopen /dev/tty if one file was zipped from stdin
  6104. X         * or if file names were read from stdin.
  6105. X         */
  6106. X        if (fgets(e, MAXCOM+1, stdin) != NULL)
  6107. X        {
  6108. X          if ((p = malloc((k = strlen(e))+1)) == NULL)
  6109. X          {
  6110. X            free((voidp *)e);
  6111. X            err(ZE_MEM, "was reading comment lines");
  6112. X          }
  6113. X          strcpy(p, e);
  6114. X          if (p[k-1] == '\n')
  6115. X            p[--k] = 0;
  6116. X          z->comment = p;
  6117. X          z->com = k;
  6118. X        }
  6119. X      }
  6120. X    free((voidp *)e);
  6121. X  }
  6122. X
  6123. X  /* Get multi-line comment for the zip file */
  6124. X  if (zipedit)
  6125. X  {
  6126. X    if ((e = malloc(MAXCOM + 1)) == NULL)
  6127. X      err(ZE_MEM, "was reading comment lines");
  6128. X    if (noisy && zcomlen)
  6129. X    {
  6130. X      fputs("current zip file comment is:\n", mesg);
  6131. X      fwrite(zcomment, 1, zcomlen, mesg);
  6132. X      if (zcomment[zcomlen-1] != '\n')
  6133. X        putc('\n', mesg);
  6134. X      free((voidp *)zcomment);
  6135. X    }
  6136. X    zcomment = malloc(1);
  6137. X    *zcomment = 0;
  6138. X    if (noisy)
  6139. X      fputs("enter new zip file comment (end with .):\n", mesg);
  6140. X     /* ??? reopen /dev/tty if one file was zipped from stdin
  6141. X      * or if file names were read from stdin.
  6142. X      */
  6143. X    while (fgets(e, MAXCOM+1, stdin) != NULL && strcmp(e, ".\n"))
  6144. X    {
  6145. X      if (e[(r = strlen(e)) - 1] == '\n')
  6146. X        e[--r] = 0;
  6147. X      if ((p = malloc((*zcomment ? strlen(zcomment) + 3 : 1) + r)) == NULL)
  6148. X      {
  6149. X        free((voidp *)e);
  6150. X        err(ZE_MEM, "was reading comment lines");
  6151. X      }
  6152. X      if (*zcomment)
  6153. X        strcat(strcat(strcpy(p, zcomment), "\r\n"), e);
  6154. X      else
  6155. X        strcpy(p, *e ? e : "\r\n");
  6156. X      free((voidp *)zcomment);
  6157. X      zcomment = p;
  6158. X    }
  6159. X    zcomlen = strlen(zcomment);
  6160. X    free((voidp *)e);
  6161. X  }
  6162. X
  6163. X
  6164. X  /* Write central directory and end header to temporary zip */
  6165. X  diag("writing central directory");
  6166. X  k = 0;                        /* keep count for end header */
  6167. X  c = tempzn;                   /* get start of central */
  6168. X  n = t = 0;
  6169. X  for (z = zfiles; z != NULL; z = z->nxt)
  6170. X  {
  6171. X    if ((r = putcentral(z, y)) != ZE_OK)
  6172. X      err(r, tempzip);
  6173. X    tempzn += 4 + CENHEAD + z->nam + z->cext + z->com;
  6174. X    n += z->len;
  6175. X    t += z->siz;
  6176. X    k++;
  6177. X  }
  6178. X  if (k == 0)
  6179. X    warn("zip file empty", "");
  6180. X  if (verbose)
  6181. X    fprintf(mesg, "total bytes=%lu, compressed=%lu -> %d%% savings\n",
  6182. X           n, t, percent(n, t));
  6183. X  t = tempzn - c;               /* compute length of central */
  6184. X  diag("writing end of central directory");
  6185. X  if ((r = putend(k, t, c, zcomlen, zcomment, y)) != ZE_OK)
  6186. X    err(r, tempzip);
  6187. X  tempzf = NULL;
  6188. X  if (fclose(y))
  6189. X    err(d ? ZE_WRITE : ZE_TEMP, tempzip);
  6190. X  if (x != NULL)
  6191. X    fclose(x);
  6192. X
  6193. X
  6194. X  /* Replace old zip file with new zip file, leaving only the new one */
  6195. X  if (strcmp(zipfile, "-") && !d)
  6196. X  {
  6197. X    diag("replacing old zip file with new zip file");
  6198. X    if ((r = replace(zipfile, tempzip)) != ZE_OK)
  6199. X    {
  6200. X      warn("new zip file left as: ", tempzip);
  6201. X      free((voidp *)tempzip);
  6202. X      tempzip = NULL;
  6203. X      err(r, "was replacing the original zip file");
  6204. X    }
  6205. X    free((voidp *)tempzip);
  6206. X  }
  6207. X  tempzip = NULL;
  6208. X  if (strcmp(zipfile, "-")) {
  6209. X    setfileattr(zipfile, a);
  6210. X#ifdef VMS
  6211. X    /* If the zip file existed previously, restore its record format: */
  6212. X    if (x != NULL)
  6213. X      VMSmunch(zipfile, RESTORE_RTYPE, NULL);
  6214. X#endif
  6215. X  }
  6216. X
  6217. X  /* Finish up (process -o, -m, clean up).  Exit code depends on o. */
  6218. X  leave(o ? ZE_OPEN : ZE_OK);
  6219. X}
  6220. X
  6221. X/*****************************************************************
  6222. X | envargs - add default options from environment to command line
  6223. X |----------------------------------------------------------------
  6224. X | Author: Bill Davidsen, original 10/13/91, revised 23 Oct 1991.
  6225. X | This program is in the public domain.
  6226. X |----------------------------------------------------------------
  6227. X | Minor program notes:
  6228. X |  1. Yes, the indirection is a tad complex
  6229. X |  2. Parenthesis were added where not needed in some cases
  6230. X |     to make the action of the code less obscure.
  6231. X ****************************************************************/
  6232. X
  6233. Xlocal void
  6234. Xenvargs(Pargc, Pargv, envstr)
  6235. Xint *Pargc;
  6236. Xchar ***Pargv;
  6237. Xchar *envstr;
  6238. X{
  6239. X    char *getenv();
  6240. X    char *envptr;                               /* value returned by getenv */
  6241. X    char *bufptr;                               /* copy of env info */
  6242. X    int argc = 0;                               /* internal arg count */
  6243. X    int ch;                                             /* spare temp value */
  6244. X    char **argv;                                /* internal arg vector */
  6245. X    char **argvect;                             /* copy of vector address */
  6246. X
  6247. X    /* see if anything in the environment */
  6248. X    envptr = getenv(envstr);
  6249. X    if (envptr == NULL || *envptr == 0) return;
  6250. X
  6251. X    /* count the args so we can allocate room for them */
  6252. X    argc = count_args(envptr);
  6253. X    bufptr = malloc(1+strlen(envptr));
  6254. X    if (bufptr == NULL)
  6255. X        err(ZE_MEM, "Can't get memory for arguments");
  6256. X
  6257. X    strcpy(bufptr, envptr);
  6258. X
  6259. X    /* allocate a vector large enough for all args */
  6260. X    argv = (char **)malloc((argc+*Pargc+1)*sizeof(char *));
  6261. X    if (argv == NULL)
  6262. X        err(ZE_MEM, "Can't get memory for arguments");
  6263. X    argvect = argv;
  6264. X
  6265. X    /* copy the program name first, that's always true */
  6266. X    *(argv++) = *((*Pargv)++);
  6267. X
  6268. X    /* copy the environment args first, may be changed */
  6269. X    do {
  6270. X        *(argv++) = bufptr;
  6271. X        /* skip the arg and any trailing blanks */
  6272. X        while ((ch = *bufptr) != '\0' && ch != ' ') ++bufptr;
  6273. X        if (ch == ' ') *(bufptr++) = '\0';
  6274. X        while ((ch = *bufptr) != '\0' && ch == ' ') ++bufptr;
  6275. X    } while (ch);
  6276. X
  6277. X    /* now save old argc and copy in the old args */
  6278. X    argc += *Pargc;
  6279. X    while (--(*Pargc)) *(argv++) = *((*Pargv)++);
  6280. X
  6281. X    /* finally, add a NULL after the last arg, like UNIX */
  6282. X    *argv = NULL;
  6283. X
  6284. X    /* save the values and return */
  6285. X    *Pargv = argvect;
  6286. X    *Pargc = argc;
  6287. X}
  6288. X
  6289. Xstatic int
  6290. Xcount_args(s)
  6291. Xchar *s;
  6292. X{
  6293. X    int count = 0;
  6294. X    int ch;
  6295. X
  6296. X    do {
  6297. X        /* count and skip args */
  6298. X        ++count;
  6299. X        while ((ch = *s) != '\0' && ch != ' ') ++s;
  6300. X        while ((ch = *s) != '\0' && ch == ' ') ++s;
  6301. X    } while (ch);
  6302. X
  6303. X    return count;
  6304. X}
  6305. END_OF_FILE
  6306.   if test 32880 -ne `wc -c <'zip.c'`; then
  6307.     echo shar: \"'zip.c'\" unpacked with wrong size!
  6308.   fi
  6309.   # end of 'zip.c'
  6310. fi
  6311. if test -f 'zip.doc' -a "${1}" != "-c" ; then 
  6312.   echo shar: Will not clobber existing file \"'zip.doc'\"
  6313. else
  6314.   echo shar: Extracting \"'zip.doc'\" \(23559 characters\)
  6315.   sed "s/^X//" >'zip.doc' <<'END_OF_FILE'
  6316. X
  6317. XZIP(1)                   USER COMMANDS                     ZIP(1)
  6318. X
  6319. XNAME
  6320. X     zip, zipcloak, zipnote,  zipsplit  -  package  and  compress
  6321. X     (archive) files
  6322. X
  6323. XSYNOPSIS
  6324. X     zip [ -cdeEfghjklmoqruwyz@ ] [ -b temppath ] [ -n suffixes ]
  6325. X     [ -t mmddyy ] [ zipfile list ] [ -x list ]
  6326. X
  6327. X     zipcloak [ -d ] [ -b path ] zipfile
  6328. X
  6329. X     zipnote [ -w ] [ -b path ] zipfile
  6330. X
  6331. X     zipsplit [ -ti ] [ -n size ] [ -b path ] zipfile
  6332. X
  6333. XDESCRIPTION
  6334. X     zip is a compression and file packaging  utility  for  Unix,
  6335. X     VMS,  MSDOS,  OS/2,  Windows NT, Minix, Atari and Macintosh.
  6336. X     It is analogous to a combination of tar and compress and  is
  6337. X     compatible with PKZIP (Phil Katz ZIP) for MSDOS systems.
  6338. X
  6339. X     There is a companion to zip called unzip (of  course)  which
  6340. X     you  should  be able to find the same place you got zip. zip
  6341. X     and unzip can work with files produced by PKZIP under MSDOS,
  6342. X     and PKZIP and PKUNZIP can work with files produced by zip.
  6343. X
  6344. X     zip version 1.9 is compatible with pkzip 1.93a.   Note  that
  6345. X     pkunzip 1.10 cannot extract files produced by pkzip 1.93a or
  6346. X     zip 1.9b. You must use pkunzip 1.93a or unzip 5.0 to extract
  6347. X     them.
  6348. X
  6349. X     For a brief help on zip and unzip, run each without specify-
  6350. X     ing any parameters on the command line.
  6351. X
  6352. X     zip puts one or more compressed files  into  a  single  "zip
  6353. X     file"  along with information about the files, including the
  6354. X     name, path if requested, date and time last  modified,  pro-
  6355. X     tection,  and  check  information  to verify the fidelity of
  6356. X     each entry.  zip can also be used as a  filter,  compressing
  6357. X     standard  input  to standard output.  zip can pack an entire
  6358. X     directory structure in a zip file  with  a  single  command.
  6359. X     Compression  ratios of 2:1 to 3:1 are common for text files.
  6360. X     zip has one compression  method  (deflation)  and  can  also
  6361. X     store  files  without  compression. It automatically chooses
  6362. X     the better of the two for each file to be compressed.
  6363. X
  6364. X     zip is useful for packaging a set of files to send to  some-
  6365. X     one  or for distribution; for archiving or backing up files;
  6366. X     and for saving disk space by temporarily compressing  unused
  6367. X     files or directories.
  6368. X
  6369. XHOW TO USE ZIP
  6370. X     The simplest use of zip is as follows:
  6371. X
  6372. X          zip stuff *
  6373. X
  6374. X     This will create the file "stuff.zip" (assuming it does  not
  6375. X     exist)  and  put  all  the files in the current directory in
  6376. X     stuff.zip in a compressed form.  The .zip  suffix  is  added
  6377. X     automatically,  unless  that  file name given contains a dot
  6378. X     already.  This allows specifying suffixes other than ".zip".
  6379. X
  6380. X     Because of the way the  shell  does  filename  substitution,
  6381. X     files  that  start  with a "." are not included.  To include
  6382. X     those as well, you can:
  6383. X
  6384. X          zip stuff .* *
  6385. X
  6386. X     Even this will not include any subdirectories  that  are  in
  6387. X     the  current  directory.  To zip up an entire directory, the
  6388. X     command:
  6389. X
  6390. X          zip -r foo foo
  6391. X
  6392. X     will create the file "foo.zip" containing all the files  and
  6393. X     directories  in  the  directory "foo" that is in the current
  6394. X     directory. (The first "foo" denotes the zip file, the second
  6395. X     one  denotes  the  directory.)  The "r" option means recurse
  6396. X     through the directory structure.   In  this  case,  all  the
  6397. X     files  and directories in foo are zipped, including the ones
  6398. X     that start with a ".", since the recursion does not use  the
  6399. X     shell's  file-name substitution.  You should not use -r with
  6400. X     the name ".*", since that matches ".." which will attempt to
  6401. X     zip up the parent directory--probably not what was intended.
  6402. X
  6403. X     You may want to make a zip file that contains the  files  in
  6404. X     foo,  but  not  record the directory name, foo.  You can use
  6405. X     the -j (junk path) option to leave off the path:
  6406. X
  6407. X          zip -j foo foo/*
  6408. X
  6409. X     The -y option (only under Unix) will store symbolic links as
  6410. X     such in the zip file, instead of compressing and storing the
  6411. X     file referred to in the link.
  6412. X
  6413. X     You might be zipping to save disk space, in which  case  you
  6414. X     could:
  6415. X
  6416. X          zip -rm foo foo
  6417. X
  6418. X     where the "m" option means "move".  This will delete foo and
  6419. X     its  contents  after  making  foo.zip.  No deletions will be
  6420. X     done until the zip  has  completed  with  no  errors.   This
  6421. X     option  is  obviously more dangerous and should be used with
  6422. X     care.
  6423. X
  6424. X     If the zip file already exists, these commands will  replace
  6425. X     existing  or  add new entries to the zip file.  For example,
  6426. X     if you were really short on disk space, you might  not  have
  6427. X     enough room simultaneously to hold the directory foo and the
  6428. X     compressed foo.zip.  In this case, you could do it in steps.
  6429. X     If  foo  contained  the subdirectories tom, dick, and harry,
  6430. X     then you could:
  6431. X
  6432. X          zip -rm foo foo/tom
  6433. X          zip -rm foo foo/dick
  6434. X          zip -rm foo foo/harry
  6435. X
  6436. X     where the first command would create foo.zip, and  the  next
  6437. X     two would add to it.  At the completion of each zip command,
  6438. X     the directory just zipped would be deleted, making  room  in
  6439. X     which the next zip command could work.
  6440. X
  6441. X     zip will also accept a single dash ("-")  as  the  zip  file
  6442. X     name,  in  which  case it will write the zip file to stdout,
  6443. X     allowing the output to be  piped  to  another  program.  For
  6444. X     example:
  6445. X
  6446. X          zip -r - . | dd of=/dev/nrst0 obs=16k
  6447. X
  6448. X     would write the zip output  directly  to  a  tape  with  the
  6449. X     specified  block  size  for  the  purpose  of backing up the
  6450. X     current directory.
  6451. X
  6452. X     zip also accepts a single dash ("-") as the name of  a  file
  6453. X     to  be  compressed,  in which case it will read the zip file
  6454. X     from stdin, allowing zip to take input from another program.
  6455. X     For example:
  6456. X
  6457. X          tar cf - . | zip backup -
  6458. X
  6459. X     would compress the output of the tar command for the purpose
  6460. X     of backing up the current directory. This generally produces
  6461. X     better compression than the previous example  using  the  -r
  6462. X     option, because zip can take advantage of redundancy between
  6463. X     files. The backup can be restored using the command
  6464. X
  6465. X          unzip -p backup | tar xf -
  6466. X
  6467. X     When no zip file name is given and stdout is not a terminal,
  6468. X     zip acts as a filter, compressing standard input to standard
  6469. X     output.  For example,
  6470. X
  6471. X          tar cf - . | zip | dd of=/dev/nrst0
  6472. X
  6473. X     is equivalent to
  6474. X
  6475. X          tar cf - . | zip - - | dd of=/dev/nrst0
  6476. X
  6477. X     Zip archives created in this manner can  be  extracted  with
  6478. X     the  program  funzip which is provided in the unzip package.
  6479. X     For example,
  6480. X
  6481. X             dd if=/dev/nrst0 | funzip | tar xvf -
  6482. X
  6483. XMODIFYING EXISTING ZIP FILES
  6484. X     When given the name of an existing zip file with  the  above
  6485. X     commands,  zip will replace identically named entries in the
  6486. X     zip file or add entries for  new  names.   For  example,  if
  6487. X     foo.zip exists and contains foo/file1 and foo/file2, and the
  6488. X     directory foo contains the files  foo/file1  and  foo/file3,
  6489. X     then:
  6490. X
  6491. X          zip -r foo foo
  6492. X
  6493. X     will replace foo/file1  in  foo.zip  and  add  foo/file3  to
  6494. X     foo.zip.  After this, foo.zip contains foo/file1, foo/file2,
  6495. X     and foo/file3, with foo/file2 unchanged from before.
  6496. X
  6497. X     When changing an existing zip file, zip will  write  a  tem-
  6498. X     porary  file with the new contents, and only replace the old
  6499. X     one when the zip has completed with no errors. You  can  use
  6500. X     the  -b  option  to specify a different path (usually a dif-
  6501. X     ferent device) to put the temporary file in.  For example:
  6502. X
  6503. X          zip -b /tmp stuff *
  6504. X
  6505. X     will put the temporary zip file and the  temporary  compres-
  6506. X     sion  files  in the directory "/tmp", copying over stuff.zip
  6507. X     in the current directory when done.
  6508. X
  6509. X     If you are only adding entries to a zip file, not replacing,
  6510. X     and  the -g option is given, then zip grows (appends to) the
  6511. X     file instead of copying it.  The danger of this is  that  if
  6512. X     the  operation fails, the original zip file is corrupted and
  6513. X     lost.
  6514. X
  6515. X     There are two other ways to change or add entries in  a  zip
  6516. X     file  that  are  restrictions of simple addition or replace-
  6517. X     ment.  The first is -u (update) which will add  new  entries
  6518. X     to  the zip file as before but will replace existing entries
  6519. X     only if the modified date of the file is  more  recent  than
  6520. X     the  date recorded for that name in the zip file.  For exam-
  6521. X     ple:
  6522. X
  6523. X          zip -u stuff *
  6524. X
  6525. X     will add any new files in the current directory, and  update
  6526. X     any  changed files in the zip file stuff.zip.  Note that zip
  6527. X     will not try to pack stuff.zip into itself when you do this.
  6528. X     zip will always exclude the zip file from the files on which
  6529. X     to be operated.
  6530. X
  6531. X     The second restriction is -f (freshen) which,  like  update,
  6532. X     will  only  replace entries with newer files; unlike update,
  6533. X     will not add files that are not already  in  the  zip  file.
  6534. X     For  this  option, you may want to simply freshen all of the
  6535. X     files that are in the specified zip file.  To  do  this  you
  6536. X     would simply:
  6537. X
  6538. X          zip -f foo
  6539. X
  6540. X     Note that the -f option with no arguments freshens  all  the
  6541. X     entries  in the zip file.  The same is true of -u, and hence
  6542. X     "zip -u foo" and "zip -f foo" both do the same thing.
  6543. X
  6544. X     This command should be run  from  the  same  directory  from
  6545. X     which  the  original zip command was run, since paths stored
  6546. X     in zip files are always relative.
  6547. X
  6548. X     Another restriction that can be used with adding,  updating,
  6549. X     or  freshening is -t (time), which will not operate on files
  6550. X     modified earlier than the specified date.  For example:
  6551. X
  6552. X          zip -rt 120791 infamy foo
  6553. X
  6554. X     will add all the files in foo and  its  subdirectories  that
  6555. X     were  last modified on December 7, 1991, or later to the zip
  6556. X     file infamy.zip.
  6557. X
  6558. X     Also, files can be explicitly excluded using the -x option:
  6559. X
  6560. X          zip -r foo foo -x \*.o
  6561. X
  6562. X     which will zip up the  contents  of  foo  into  foo.zip  but
  6563. X     exclude  all the files that end in ".o".  Here the backslash
  6564. X     causes zip to match file names that were found when foo  was
  6565. X     searched.
  6566. X
  6567. X     The last operation is -d (delete) which will remove  entries
  6568. X     from a zip file.  An example might be:
  6569. X
  6570. X          zip -d foo foo/tom/junk foo/harry/\* \*.o
  6571. X
  6572. X     which will remove the entry foo/tom/junk, all of  the  files
  6573. X     that  start with "foo/harry/", and all of the files that end
  6574. X     with ".o" (in any path).  Note that once  again,  the  shell
  6575. X     expansion  has  been inhibited with backslashes, so that zip
  6576. X     can see the asterisks. zip can then match on the contents of
  6577. X     the  zip  file instead of the contents of the current direc-
  6578. X     tory.
  6579. X
  6580. X     Under MSDOS, -d is case sensitive when it matches  names  in
  6581. X     the  zip  file.  This allows deleting names that were zipped
  6582. X     on other systems, but requires that the names be entered  in
  6583. X     upper  case  if they were zipped on an MSDOS system, so that
  6584. X     the names can be found in the zip file and deleted.
  6585. X
  6586. XMORE OPTIONS
  6587. X     As mentioned before, zip will use the best of  two  methods:
  6588. X     deflate or store.
  6589. X
  6590. X     The option -0 will force zip to use store on all files.  For
  6591. X     example:
  6592. X
  6593. X          zip -r0 foo foo
  6594. X
  6595. X     will zip up the directory foo into foo.zip using only store.
  6596. X
  6597. X     The speed of deflation can also be controlled  with  options
  6598. X     -1  (fastest  method  but  less  compression)  to  -9  (best
  6599. X     compression but slower). The default value is -5. For  exam-
  6600. X     ple:
  6601. X
  6602. X          zip -r8 foo foo
  6603. X
  6604. X     In nearly all cases, a file that is already compressed  can-
  6605. X     not  be  compressed further by zip, or if it can, the effect
  6606. X     is minimal.  The -n  option  prevents  zip  from  trying  to
  6607. X     compress files that have the given suffixes.  Such files are
  6608. X     simply stored (0% compression) in the output  zip  file,  so
  6609. X     that  zip  doesn't  waste  its time trying to compress them.
  6610. X     The suffixes are separated by either colons  or  semicolons.
  6611. X     For example:
  6612. X
  6613. X          zip -rn ".Z:.zip:.tiff:.gif:.snd"  foo foo
  6614. X
  6615. X     will put everything in foo into foo.zip, but will store  any
  6616. X     files  that  end  in  .Z, .zip, .tiff, .gif, or .snd without
  6617. X     trying to compress them.  (Image and sound files often  have
  6618. X     their own specialized compression methods.) The default suf-
  6619. X     fix list is ".Z:.zip;.zoo:.arc:.lzh:.arj".  The  environment
  6620. X     variable  ZIPOPT  can  be  used  to change this default. For
  6621. X     example under Unix with csh:
  6622. X
  6623. X          setenv ZIPOPT "-n .gif:.zip"
  6624. X
  6625. X     The variable ZIPOPT can be  used  for  any  option  and  can
  6626. X     include several options.
  6627. X
  6628. X     Under Unix and  under  OS/2  (if  files  from  an  HPFS  are
  6629. X     stored),  zip  will  store  the  full  path (relative to the
  6630. X     current path) and name of the file (or just the name  if  -j
  6631. X     is   specified)   in  the  zip  file  along  with  the  Unix
  6632. X     attributes, and it will mark the entry as made  under  Unix.
  6633. X     If  the  zip  file is intended for PKUNZIP under MSDOS, then
  6634. X     the -k (Katz) option should be used to  attempt  to  convert
  6635. X     the  names  and  paths  to  conform to MSDOS, store only the
  6636. X     MSDOS attribute (just the user write attribute  from  Unix),
  6637. X     and  mark  the  entry  as  made  under MSDOS (even though it
  6638. X     wasn't).
  6639. X
  6640. X     The -o (older) option will set the "last modified"  time  of
  6641. X     the  zip  file  to  the  latest  "last modified" time of the
  6642. X     entries in the zip file.  This can be used without any other
  6643. X     operations, if desired.  For example:
  6644. X
  6645. X          zip -o foo
  6646. X
  6647. X     will change the last modified time of foo.zip to the  latest
  6648. X     time of the entries in foo.zip.
  6649. X
  6650. X     The -e and -c options operate on all files updated or  added
  6651. X     to the zip file.  Encryption (-e) will prompt for a password
  6652. X     on the terminal and will not echo  the  password  as  it  is
  6653. X     typed (if stderr is not a TTY, zip will exit with an error).
  6654. X     New zip entries will be encrypted using that password.   For
  6655. X     added  peace of mind, you can use -ee, which will prompt for
  6656. X     the password twice, checking  that  the  two  are  the  same
  6657. X     before   using   it.  The  encryption  code  is  distributed
  6658. X     separately, so the -e option may not be  available  in  your
  6659. X     version.
  6660. X
  6661. X     One-line comments can be added for each  file  with  the  -c
  6662. X     option.   The  zip file operations (adding or updating) will
  6663. X     be done first, and you will then be prompted for a  one-line
  6664. X     comment  for each file.  You can then enter the comment fol-
  6665. X     lowed by return, or just return for no comment.
  6666. X
  6667. X     The -z option will prompt you for a multi-line  comment  for
  6668. X     the  entire zip file.  This option can be used by itself, or
  6669. X     in combination with other options.  The comment is ended  by
  6670. X     a line containing just a period, or an end of file condition
  6671. X     (^D on Unix, ^Z on MSDOS,  OS/2,  and  VAX/VMS).   Since  -z
  6672. X     reads  the lines from stdin, you can simply take the comment
  6673. X     from a file:
  6674. X
  6675. X          zip -z foo < foowhat
  6676. X
  6677. X     The -q (quiet) option eliminates the informational  messages
  6678. X     and  comment  prompts while zip is operating.  This might be
  6679. X     used in shell scripts, for example, or if the zip  operation
  6680. X     is  being  performed  as  a background task ("zip -q foo *.c
  6681. X     &").
  6682. X
  6683. X     zip can take a list of file names to operate on  from  stdin
  6684. X     using  the -@ option.  In Unix, this option can be used with
  6685. X     the find command to extend greatly the functionality of zip.
  6686. X     For example, to zip up all the C source files in the current
  6687. X     directory and its subdirectories, you can:
  6688. X
  6689. X          find . -type f -name "*.[ch]" -print | zip source -@
  6690. X
  6691. X     Note that the pattern must be quoted to keep the shell  from
  6692. X     expanding it.
  6693. X
  6694. X     Under VMS only, the -w option will append the version number
  6695. X     of  the  files  to  the name and zip up multiple versions of
  6696. X     files.  Without -w, zip will only use the most  recent  ver-
  6697. X     sion of the specified file(s).
  6698. X
  6699. X     The -l option translates the Unix end-of-line  character  LF
  6700. X     into  the  MSDOS convention CR LF. This option should not be
  6701. X     used on binary files.  This option can be used  on  Unix  if
  6702. X     the  zip  file  is  intended for PKUNZIP under MSDOS. If the
  6703. X     input files already contain CR LF, this option adds an extra
  6704. X     CR.  This  ensure  that  "unzip -a" on Unix will get back an
  6705. X     exact copy of the original file, to undo the effect of  "zip
  6706. X     -l".
  6707. X
  6708. X     If zip is run with the -h option, or with no  arguments  and
  6709. X     standard  output is a terminal, the license and the command-
  6710. X     argument and option help is shown.  The -L option just shows
  6711. X     the license.
  6712. X
  6713. XABOUT PATTERN MATCHING
  6714. X     (Note: this section applies to Unix.  Watch this  space  for
  6715. X     details on MSDOS and VMS operation.)
  6716. X
  6717. X     The Unix shell (sh or csh)  does  filename  substitution  on
  6718. X     command  arguments.   The  special  characters  are ?, which
  6719. X     matches any single character; * which matches any number  of
  6720. X     characters  (including none); and [] which matches any char-
  6721. X     acter in the  range  inside  the  brackets  (like  [a-f]  or
  6722. X     [0-9]).   When  these  characters  are  encountered (and not
  6723. X     escaped with a backslash or quotes), the shell will look for
  6724. X     files  relative  to the current path that match the pattern,
  6725. X     and replace the argument with  a  list  of  the  names  that
  6726. X     matched.
  6727. X
  6728. X     zip can do the same matching on names that are  in  the  zip
  6729. X     file  being  modified  or,  in  the case of the -x (exclude)
  6730. X     option, on the list of files to be  operated  on,  by  using
  6731. X     backslashes  or  quotes to tell the shell not to do the name
  6732. X     expansion.  In general, when zip encounters a  name  in  the
  6733. X     list of files to do, it first looks for the name in the file
  6734. X     system.  If it finds it, it then adds  it  to  the  list  of
  6735. X     files  to  do.  If it does not find it, it will look for the
  6736. X     name in the zip file being modified (if  it  exists),  using
  6737. X     the  pattern  matching  characters  above, if any.  For each
  6738. X     match, it will add that name to the list  of  files  to  do.
  6739. X     After  -x  (exclude),  the  names are removed from the to-do
  6740. X     list instead of added.
  6741. X
  6742. X     The pattern matching includes the path, and so patterns like
  6743. X     \*.o  match  names that end in ".o", no matter what the path
  6744. X     prefix is.  Note that the backslash must precede every  spe-
  6745. X     cial  character  (i.e. ?*[]), or the entire argument must be
  6746. X     enclosed in double quotes ("").
  6747. X
  6748. X     In general, using backslash  to  make  zip  do  the  pattern
  6749. X     matching  is  used  with  the  -f  (freshen) and -d (delete)
  6750. X     options, and sometimes after the -x  (exclude)  option  when
  6751. X     used  with  any  operation  (add,  -u, -f, or -d).  zip will
  6752. X     never use pattern matching to search the  file  system.   If
  6753. X     zip has recursed into a directory, all files (and all direc-
  6754. X     tories) in there are fair game.
  6755. X
  6756. XCOPYRIGHT
  6757. X     Copyright (C) 1990-1992 Mark Adler, Richard B. Wales,  Jean-
  6758. X     loup  Gailly, Kai Uwe Rommel and Igor Mandrichenko.  Permis-
  6759. X     sion is granted to any individual  or  institution  to  use,
  6760. X     copy,  or  redistribute  this software so long as all of the
  6761. X     original files are included unmodified, that it is not  sold
  6762. X     for profit, and that this copyright notice is retained.
  6763. X
  6764. XACKNOWLEDGEMENTS
  6765. X     Thanks to R. P.  Byrne  for  his  Shrink.Pas  program  which
  6766. X     inspired  this project; to Phil Katz for making the zip file
  6767. X     format, compression format, and .zip filename extension  all
  6768. X     public  domain;  to  Steve  Burg  and  Phil Katz for help on
  6769. X     unclear points of the deflate format; to Keith Petersen  and
  6770. X     Rich Wales for providing a mailing list and ftp site for the
  6771. X     INFO-ZIP group to use; and most importantly, to the INFO-ZIP
  6772. X     group  itself (listed in the file infozip.who) without whose
  6773. X     tireless testing and bug-fixing efforts a portable zip would
  6774. X     not have been possible.  Finally we should thank (blame) the
  6775. X     INFO-ZIP moderator, David Kirschbaum  for  getting  us  into
  6776. X     this mess in the first place.
  6777. X
  6778. XSEE ALSO
  6779. X     unzip(1), tar(1), compress(1)
  6780. X
  6781. XBUGS
  6782. X     WARNING: zip files produced by this version of zip must  not
  6783. X     be  *updated*  by  zip  1.0 or pkzip 1.10 or pkzip 1.93a, if
  6784. X     they contain encrypted members, or if they  have  been  pro-
  6785. X     duced  in  a  pipe or on a non seekable device. The old ver-
  6786. X     sions of zip or pkzip would destroy the zip  structure.  The
  6787. X     old  versions can list the contents of the zip file but can-
  6788. X     not extract it anyway (because of the new compression  algo-
  6789. X     rithm).   If  you do not use encryption and use regular disk
  6790. X     files, you do not have to care about this problem.
  6791. X
  6792. X     zip 1.9 is compatible with  pkzip  1.93a,  except  when  two
  6793. X     features  are used: encryption or zip file created in a pipe
  6794. X     or on a non seekable device. pkzip versions above  2.0  will
  6795. X     support such files, and unzip 5.0 already supports them.
  6796. X
  6797. X     Without -y, when zip must compress a symbolic link to an non
  6798. X     existing   file,  it  only  displays  a  warning  "name  not
  6799. X     matched". A better warnign should be given.
  6800. X
  6801. X     Under VMS, not all of the odd file formats are treated prop-
  6802. X     erly.   Only  zip files of format stream-LF and fixed length
  6803. X     512 are expected to work with zip.  Others can be  converted
  6804. X     using  Rahul Dhesi's BILF program.  This version of zip does
  6805. X     handle some of the conversion internally.  When using Kermit
  6806. X     to transfer zip files from Vax to MSDOS, type "set file type
  6807. X     block" on the Vax.  When transfering from MSDOS to Vax, type
  6808. X     "set  file type fixed" on the Vax.  In both cases, type "set
  6809. X     file type binary" on MSDOS.
  6810. X
  6811. X     Under VMS, zip hangs for file specification that uses DECnet
  6812. X     syntax (foo::*.*).
  6813. X
  6814. X     Under OS/2, the amount of External Attributes  displayed  by
  6815. X     DIR is (for compatibility) the amount returned by the 16-bit
  6816. X     version of DosQueryPathInfo(). Otherwise OS/2  1.3  and  2.0
  6817. X     would  report  different  EA sizes when DIRing a file.  How-
  6818. X     ever,  the  structure  layout   returned   by   the   32-bit
  6819. X     DosQueryPathInfo() is a bit different, it uses extra padding
  6820. X     bytes and link pointers (it's a linked  list)  to  have  all
  6821. X     fields  on  4-byte boundaries for portability to future RISC
  6822. X     OS/2 versions. Therefore the value reported  by  ZIP  (which
  6823. X     uses  this  32-bit-mode  size) differs from that reported by
  6824. X     DIR.  ZIP stores the 32-bit format for portability, even the
  6825. X     16-bit  MS-C-compiled  version  running on OS/2 1.3, so even
  6826. X     this one shows the 32-bit-mode size.
  6827. X
  6828. X     LIKE ANYTHING ELSE THAT'S FREE, ZIP AND ITS ASSOCIATED UTIL-
  6829. X     ITIES  ARE  PROVIDED  AS IS AND COME WITH NO WARRANTY OF ANY
  6830. X     KIND, EITHER EXPRESSED OR IMPLIED.  IN  NO  EVENT  WILL  THE
  6831. X     COPYRIGHT  HOLDERS  BE LIABLE FOR ANY DAMAGES RESULTING FROM
  6832. X     THE USE OF THIS SOFTWARE.
  6833. X
  6834. X     That having been said, please send any problems or  comments
  6835. X     via email to the Internet address zip-bugs@cs.ucla.edu.  For
  6836. X     bug reports, please include the version  of  zip,  the  make
  6837. X     options  you  used  to compile it, the machine and operating
  6838. X     system you are using, and as much additional information  as
  6839. X     possible.  Thank you for your support.
  6840. END_OF_FILE
  6841.   if test 23559 -ne `wc -c <'zip.doc'`; then
  6842.     echo shar: \"'zip.doc'\" unpacked with wrong size!
  6843.   fi
  6844.   # end of 'zip.doc'
  6845. fi
  6846. echo shar: End of archive 4 \(of 11\).
  6847. cp /dev/null ark4isdone
  6848. MISSING=""
  6849. for I in 1 2 3 4 5 6 7 8 9 10 11 ; do
  6850.     if test ! -f ark${I}isdone ; then
  6851.     MISSING="${MISSING} ${I}"
  6852.     fi
  6853. done
  6854. if test "${MISSING}" = "" ; then
  6855.     echo You have unpacked all 11 archives.
  6856.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  6857. else
  6858.     echo You still must unpack the following archives:
  6859.     echo "        " ${MISSING}
  6860. fi
  6861. exit 0
  6862. exit 0 # Just in case...
  6863. Newsgroups: comp.sources.misc
  6864. From: zip-bugs@cs.ucla.edu (Info-ZIP group)
  6865. Subject:  v31i097:  zip19 - Info-ZIP portable Zip, version 1.9, Part05/11
  6866. Message-ID: <1992Aug23.064651.29195@sparky.imd.sterling.com>
  6867. X-Md4-Signature: f24a52a163a98ace3a9e3abdcc1ead76
  6868. Date: Sun, 23 Aug 1992 06:46:51 GMT
  6869. Approved: kent@sparky.imd.sterling.com
  6870.  
  6871. Submitted-by: zip-bugs@cs.ucla.edu (Info-ZIP group)
  6872. Posting-number: Volume 31, Issue 97
  6873. Archive-name: zip19/part05
  6874. Supersedes: zip: Volume 23, Issue 88-96
  6875. Environment: UNIX, VMS, OS/2, MS-DOS, MACINTOSH, WIN-NT, LINUX, MINIX, XOS, !AMIGA, ATARI, symlink, SGI, DEC, Cray, Convex, Amdahl, Sun, PC
  6876.  
  6877. #! /bin/sh
  6878. # This is a shell archive.  Remove anything before this line, then feed it
  6879. # into a shell via "sh file" or similar.  To overwrite existing files,
  6880. # type "sh file -c".
  6881. # The tool that generated this appeared in the comp.sources.unix newsgroup;
  6882. # send mail to comp-sources-unix@uunet.uu.net if you want that tool.
  6883. # Contents:  deflate.c msdos/tcconfig.tc.UU os2/os2zip.c.UU
  6884. # Wrapped by kent@sparky on Sun Aug 23 01:00:44 1992
  6885. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  6886. echo If this archive is complete, you will see the following message:
  6887. echo '          "shar: End of archive 5 (of 11)."'
  6888. if test -f 'deflate.c' -a "${1}" != "-c" ; then 
  6889.   echo shar: Will not clobber existing file \"'deflate.c'\"
  6890. else
  6891.   echo shar: Extracting \"'deflate.c'\" \(26162 characters\)
  6892.   sed "s/^X//" >'deflate.c' <<'END_OF_FILE'
  6893. X/*
  6894. X
  6895. X Copyright (C) 1990-1992 Mark Adler, Richard B. Wales, Jean-loup Gailly,
  6896. X Kai Uwe Rommel and Igor Mandrichenko.
  6897. X Permission is granted to any individual or institution to use, copy, or
  6898. X redistribute this software so long as all of the original files are included
  6899. X unmodified, that it is not sold for profit, and that this copyright notice
  6900. X is retained.
  6901. X
  6902. X*/
  6903. X
  6904. X/*
  6905. X *  deflate.c by Jean-loup Gailly.
  6906. X *
  6907. X *  PURPOSE
  6908. X *
  6909. X *      Identify new text as repetitions of old text within a fixed-
  6910. X *      length sliding window trailing behind the new text.
  6911. X *
  6912. X *  DISCUSSION
  6913. X *
  6914. X *      The "deflation" process depends on being able to identify portions
  6915. X *      of the input text which are identical to earlier input (within a
  6916. X *      sliding window trailing behind the input currently being processed).
  6917. X *
  6918. X *      The most straightforward technique turns out to be the fastest for
  6919. X *      most input files: try all possible matches and select the longest.
  6920. X *      The key feature is of this algorithm is that insertion and deletions
  6921. X *      from the string dictionary are very simple and thus fast. Insertions
  6922. X *      and deletions are performed at each input character, whereas string
  6923. X *      matches are performed only when the previous match ends. So it is
  6924. X *      preferable to spend more time in matches to allow very fast string
  6925. X *      insertions and deletions. The matching algorithm for small strings
  6926. X *      is inspired from that of Rabin & Karp. A brute force approach is
  6927. X *      used to find longer strings when a small match has been found.
  6928. X *      A similar algorithm is used in comic (by Jan-Mark Wams) and freeze
  6929. X *      (by Leonid Broukhis).
  6930. X *         A previous version of this file used a more sophisticated algorithm
  6931. X *      (by Fiala and Greene) which is guaranteed to run in linear amortized
  6932. X *      time, but has a larger average cost and uses more memory. However
  6933. X *      the F&G algorithm may be faster for some highly redundant files if
  6934. X *      the parameter max_chain_length (described below) is too large.
  6935. X *
  6936. X *  ACKNOWLEDGEMENTS
  6937. X *
  6938. X *      The idea of lazy evaluation of matches is due to Jan-Mark Wams, and
  6939. X *      I found it in 'freeze' written by Leonid Broukhis.
  6940. X *      Thanks to many info-zippers for bug reports and testing.
  6941. X *
  6942. X *  REFERENCES
  6943. X *
  6944. X *      APPNOTE.TXT documentation file in PKZIP 2.0 distribution.
  6945. X *
  6946. X *      A description of the Rabin and Karp algorithm is given in the book
  6947. X *         "Algorithms" by R. Sedgewick, Addison-Wesley, p252.
  6948. X *
  6949. X *      Fiala,E.R., and Greene,D.H.
  6950. X *         Data Compression with Finite Windows, Comm.ACM, 32,4 (1989) 490-595
  6951. X *
  6952. X *  INTERFACE
  6953. X *
  6954. X *      void lm_init (int pack_level, ush *flags)
  6955. X *          Initialize the "longest match" routines for a new file
  6956. X *
  6957. X *      ulg deflate (void)
  6958. X *          Processes a new input file and return its compressed length. Sets
  6959. X *          the compressed length, crc, deflate flags and internal file
  6960. X *          attributes.
  6961. X */
  6962. X
  6963. X#include "zip.h"
  6964. X
  6965. X/* ===========================================================================
  6966. X * Configuration parameters
  6967. X */
  6968. X
  6969. X/* Compile with MEDIUM_MEM to reduce the memory requirements or
  6970. X * with SMALL_MEM to use as little memory as possible.
  6971. X * Warning: defining these symbols affects MATCH_BUFSIZE and HASH_BITS
  6972. X * (see below) and thus affects the compression ratio. The compressed output
  6973. X * is still correct, and might even be smaller in some cases.
  6974. X */
  6975. X
  6976. X#ifdef SMALL_MEM
  6977. X#   define HASH_BITS  13  /* Number of bits used to hash strings */
  6978. X#else
  6979. X#ifdef MEDIUM_MEM
  6980. X#   define HASH_BITS  14
  6981. X#else
  6982. X#   define HASH_BITS  15
  6983. X   /* For portability to 16 bit machines, do not use values above 15. */
  6984. X#endif
  6985. X#endif
  6986. X
  6987. X#define HASH_SIZE (unsigned)(1<<HASH_BITS)
  6988. X#define HASH_MASK (HASH_SIZE-1)
  6989. X#define WMASK     (WSIZE-1)
  6990. X/* HASH_SIZE and WSIZE must be powers of two */
  6991. X
  6992. X#define NIL 0
  6993. X/* Tail of hash chains */
  6994. X
  6995. X#define FAST 4
  6996. X#define SLOW 2
  6997. X/* speed options for the general purpose bit flag */
  6998. X
  6999. X#ifndef TOO_FAR
  7000. X#  define TOO_FAR 4096
  7001. X#endif
  7002. X/* Matches of length 3 are discarded if their distance exceeds TOO_FAR */
  7003. X
  7004. X/* ===========================================================================
  7005. X * Local data used by the "longest match" routines.
  7006. X */
  7007. X
  7008. Xtypedef ush Pos;
  7009. Xtypedef unsigned IPos;
  7010. X/* A Pos is an index in the character window. We use short instead of int to
  7011. X * save space in the various tables. IPos is used only for parameter passing.
  7012. X */
  7013. X
  7014. X#ifndef DYN_ALLOC
  7015. X  uch    far window[2L*WSIZE];
  7016. X  /* Sliding window. Input bytes are read into the second half of the window,
  7017. X   * and move to the first half later to keep a dictionary of at least WSIZE
  7018. X   * bytes. With this organization, matches are limited to a distance of
  7019. X   * WSIZE-MAX_MATCH bytes, but this ensures that IO is always
  7020. X   * performed with a length multiple of the block size. Also, it limits
  7021. X   * the window size to 64K, which is quite useful on MSDOS.
  7022. X   * To do: limit the window size to WSIZE+BSZ if SMALL_MEM (the code would
  7023. X   * be less efficient since the data would have to be copied WSIZE/BSZ times)
  7024. X   */
  7025. X  Pos    far prev[WSIZE];
  7026. X  /* Link to older string with same hash index. To limit the size of this
  7027. X   * array to 64K, this link is maintained only for the last 32K strings.
  7028. X   * An index in this array is thus a window index modulo 32K.
  7029. X   */
  7030. X  Pos    far head[HASH_SIZE];
  7031. X  /* Heads of the hash chains or NIL */
  7032. X#else
  7033. X  uch    far * near window = NULL;
  7034. X  Pos    far * near prev   = NULL;
  7035. X  Pos    far * near head;
  7036. X#endif
  7037. X
  7038. Xlong block_start;
  7039. X/* window position at the beginning of the current output block. Gets
  7040. X * negative when the window is moved backwards.
  7041. X */
  7042. X
  7043. Xlocal unsigned near ins_h;  /* hash index of string to be inserted */
  7044. X
  7045. X#define H_SHIFT  ((HASH_BITS+MIN_MATCH-1)/MIN_MATCH)
  7046. X/* Number of bits by which ins_h and del_h must be shifted at each
  7047. X * input step. It must be such that after MIN_MATCH steps, the oldest
  7048. X * byte no longer takes part in the hash key, that is:
  7049. X *   H_SHIFT * MIN_MATCH >= HASH_BITS
  7050. X */
  7051. X
  7052. Xunsigned int near prev_length;
  7053. X/* Length of the best match at previous step. Matches not greater than this
  7054. X * are discarded. This is used in the lazy match evaluation.
  7055. X */
  7056. X
  7057. X      unsigned near strstart;      /* start of string to insert */
  7058. X      unsigned near match_start;   /* start of matching string */
  7059. Xlocal int      near eofile;        /* flag set at end of input file */
  7060. Xlocal unsigned near lookahead;     /* number of valid bytes ahead in window */
  7061. X
  7062. Xunsigned near max_chain_length;
  7063. X/* To speed up deflation, hash chains are never searched beyond this length.
  7064. X * A higher limit improves compression ratio but degrades the speed.
  7065. X */
  7066. X
  7067. Xlocal unsigned int max_lazy_match;
  7068. X/* Attempt to find a better match only when the current match is strictly
  7069. X * smaller than this value.
  7070. X */
  7071. X
  7072. Xint near good_match;
  7073. X/* Use a faster search when the previous match is longer than this */
  7074. X
  7075. X
  7076. X/* Values for max_lazy_match, good_match and max_chain_length, depending on
  7077. X * the desired pack level (0..9). The values given below have been tuned to
  7078. X * exclude worst case performance for pathological files. Better values may be
  7079. X * found for specific files.
  7080. X */
  7081. Xtypedef struct config {
  7082. X   int good_length;
  7083. X   int max_lazy;
  7084. X   unsigned max_chain;
  7085. X   uch flag;
  7086. X} config;
  7087. X
  7088. Xlocal config configuration_table[10] = {
  7089. X/*      good lazy chain flag */
  7090. X/* 0 */ {0,    0,    0,  0},     /* store only */
  7091. X/* 1 */ {4,    4,   16,  FAST},  /* maximum speed  */
  7092. X/* 2 */ {6,    8,   16,  0},
  7093. X/* 3 */ {8,   16,   32,  0},
  7094. X/* 4 */ {8,   32,   64,  0},
  7095. X/* 5 */ {8,   64,  128,  0},
  7096. X/* 6 */ {8,  128,  256,  0},
  7097. X/* 7 */ {8,  128,  512,  0},
  7098. X/* 8 */ {32, 258, 1024,  0},
  7099. X/* 9 */ {32, 258, 4096,  SLOW}}; /* maximum compression */
  7100. X
  7101. X/* Note: the current code requires max_lazy >= MIN_MATCH and max_chain >= 4
  7102. X * but these restrictions can easily be removed at a small cost.
  7103. X */
  7104. X
  7105. X#define EQUAL 0
  7106. X/* result of memcmp for equal strings */
  7107. X
  7108. X/* ===========================================================================
  7109. X *  Prototypes for local functions. Use asm version by default for
  7110. X *  MSDOS but not Unix. However the asm version version is recommended
  7111. X *  for 386 Unix.
  7112. X */
  7113. X#ifdef ATARI_ST
  7114. X#  undef MSDOS /* avoid the processor specific parts */
  7115. X#endif
  7116. X#if defined(MSDOS) && !defined(NO_ASM) && !defined(ASM)
  7117. X#  define ASM
  7118. X#endif
  7119. X
  7120. Xlocal void fill_window   OF((void));
  7121. X      int  longest_match OF((IPos cur_match));
  7122. X#ifdef ASM
  7123. X      void match_init OF((void)); /* asm code initialization */
  7124. X#endif
  7125. X
  7126. X#ifdef DEBUG
  7127. Xlocal  void check_match OF((IPos start, IPos match, int length));
  7128. X#endif
  7129. X
  7130. X#define MIN(a,b) ((a) <= (b) ? (a) : (b))
  7131. X/* The arguments must not have side effects. */
  7132. X
  7133. X/* ===========================================================================
  7134. X * Update a hash value with the given input byte
  7135. X * IN  assertion: all calls to to UPDATE_HASH are made with consecutive
  7136. X *    input characters, so that a running hash key can be computed from the
  7137. X *    previous key instead of complete recalculation each time.
  7138. X */
  7139. X#define UPDATE_HASH(h,c) (h = (((h)<<H_SHIFT) ^ (c)) & HASH_MASK)
  7140. X
  7141. X/* ===========================================================================
  7142. X * Insert string s in the dictionary and set match_head to the previous head
  7143. X * of the hash chain (the most recent string with same hash key). Return
  7144. X * the previous length of the hash chain.
  7145. X * IN  assertion: all calls to to INSERT_STRING are made with consecutive
  7146. X *    input characters and the first MIN_MATCH bytes of s are valid
  7147. X *    (except for the last MIN_MATCH-1 bytes of the input file).
  7148. X */
  7149. X#define INSERT_STRING(s, match_head) \
  7150. X   (UPDATE_HASH(ins_h, window[(s) + MIN_MATCH-1]), \
  7151. X    prev[(s) & WMASK] = match_head = head[ins_h], \
  7152. X    head[ins_h] = (s))
  7153. X
  7154. X/* ===========================================================================
  7155. X * Initialize the "longest match" routines for a new file
  7156. X */
  7157. Xvoid lm_init (pack_level, flags)
  7158. X    int pack_level; /* 0: store, 1: best speed, 9: best compression */
  7159. X    ush *flags;     /* general purpose bit flag */
  7160. X{
  7161. X    register unsigned j;
  7162. X
  7163. X    if (pack_level < 1 || pack_level > 9) error("bad pack level");
  7164. X
  7165. X    /* Use dynamic allocation if compiler does not like big static arrays: */
  7166. X#ifdef DYN_ALLOC
  7167. X    if (window == NULL) {
  7168. X        window = (uch far*) fcalloc(WSIZE,   2*sizeof(uch));
  7169. X        prev   = (Pos far*) fcalloc(WSIZE,     sizeof(Pos));
  7170. X        head   = (Pos far*) fcalloc(HASH_SIZE, sizeof(Pos));
  7171. X
  7172. X        if (window == NULL || prev == NULL || head == NULL) {
  7173. X            err(ZE_MEM, "window allocation");
  7174. X        }
  7175. X    }
  7176. X#endif /* DYN_ALLOC */
  7177. X#ifdef ASM
  7178. X    match_init(); /* initialize the asm code */
  7179. X#endif
  7180. X    /* Initialize the hash table. */
  7181. X    for (j = 0;  j < HASH_SIZE; j++) head[j] = NIL;
  7182. X    /* prev will be initialized on the fly */
  7183. X
  7184. X    /* Set the default configuration parameters:
  7185. X     */
  7186. X    max_lazy_match   = configuration_table[pack_level].max_lazy;
  7187. X    good_match       = configuration_table[pack_level].good_length;
  7188. X    max_chain_length = configuration_table[pack_level].max_chain;
  7189. X    *flags          |= configuration_table[pack_level].flag;
  7190. X    /* ??? reduce max_chain_length for binary files */
  7191. X
  7192. X    strstart = 0;
  7193. X    block_start = 0L;
  7194. X
  7195. X#if defined(MSDOS) && !defined(__32BIT__)
  7196. X    /* Can't read a 64K block under MSDOS */
  7197. X    lookahead = read_buf((char*)window, (unsigned)WSIZE);
  7198. X#else
  7199. X    lookahead = read_buf((char*)window, 2*WSIZE);
  7200. X#endif
  7201. X    if (lookahead == 0 || lookahead == (unsigned)EOF) {
  7202. X       eofile = 1, lookahead = 0;
  7203. X       return;
  7204. X    }
  7205. X    eofile = 0;
  7206. X    /* Make sure that we always have enough lookahead. This is important
  7207. X     * if input comes from a device such as a tty.
  7208. X     */
  7209. X    while (lookahead < MIN_LOOKAHEAD && !eofile) fill_window();
  7210. X
  7211. X    ins_h = 0;
  7212. X    for (j=0; j<MIN_MATCH-1; j++) UPDATE_HASH(ins_h, window[j]);
  7213. X    /* If lookahead < MIN_MATCH, ins_h is garbage, but this is
  7214. X     * not important since only literal bytes will be emitted.
  7215. X     */
  7216. X}
  7217. X
  7218. X/* ===========================================================================
  7219. X * Set match_start to the longest match starting at the given string and
  7220. X * return its length. Matches shorter or equal to prev_length are discarded,
  7221. X * in which case the result is equal to prev_length and match_start is
  7222. X * garbage.
  7223. X * IN assertions: cur_match is the head of the hash chain for the current
  7224. X *   string (strstart) and its distance is <= MAX_DIST, and prev_length >= 1
  7225. X */
  7226. X#ifndef ASM
  7227. X/* For MSDOS, OS/2 and 386 Unix, an optimized version is in match.asm. The code
  7228. X * is functionally equivalent, so you can use the C version if desired.
  7229. X */
  7230. Xint longest_match(cur_match)
  7231. X    IPos cur_match;                             /* current match */
  7232. X{
  7233. X    unsigned chain_length = max_chain_length;   /* max hash chain length */
  7234. X    register uch far *scan = window + strstart; /* current string */
  7235. X    register uch far *match = scan;             /* matched string */
  7236. X    register int len;                           /* length of current match */
  7237. X    int best_len = prev_length;                 /* best match length so far */
  7238. X    IPos limit = strstart > (IPos)MAX_DIST ? strstart - (IPos)MAX_DIST : NIL;
  7239. X    /* Stop when cur_match becomes <= limit. To simplify the code,
  7240. X     * we prevent matches with the string of window index 0.
  7241. X     */
  7242. X#ifdef UNALIGNED_OK
  7243. X    register ush scan_start = *(ush*)scan;
  7244. X    register ush scan_end   = *(ush*)(scan+best_len-1);
  7245. X#else
  7246. X    register uch scan_start = *scan;
  7247. X    register uch scan_end1  = scan[best_len-1];
  7248. X    register uch scan_end   = scan[best_len];
  7249. X#endif
  7250. X
  7251. X    /* Do not waste too much time if we already have a good match: */
  7252. X    if (prev_length >= good_match) {
  7253. X        chain_length >>= 2;
  7254. X    }
  7255. X
  7256. X    do {
  7257. X        Assert(cur_match < strstart, "no future");
  7258. X        match = window + cur_match;
  7259. X
  7260. X        /* Skip to next match if the match length cannot increase
  7261. X         * or if the match length is less than 2:
  7262. X         */
  7263. X#if (defined(UNALIGNED_OK) && HASH_BITS >= 8)
  7264. X        /* This code assumes sizeof(unsigned short) == 2 and
  7265. X         * sizeof(unsigned long) == 4. Do not use UNALIGNED_OK if your
  7266. X         * compiler uses different sizes.
  7267. X         */
  7268. X        if (*(ush*)(match+best_len-1) != scan_end ||
  7269. X            *(ush*)match != scan_start) continue;
  7270. X
  7271. X        len = MIN_MATCH - 4;
  7272. X        /* It is not necessary to compare scan[2] and match[2] since they are
  7273. X         * always equal when the other bytes match, given that the hash keys
  7274. X         * are equal and that HASH_BITS >= 8.
  7275. X         */
  7276. X        do {} while ((len+=4) < MAX_MATCH-3 &&
  7277. X                     *(ulg*)(scan+len) == *(ulg*)(match+len));
  7278. X        /* The funny do {} generates better code for most compilers */
  7279. X
  7280. X        if (*(ush*)(scan+len) == *(ush*)(match+len)) len += 2;
  7281. X        if (scan[len] == match[len]) len++;
  7282. X
  7283. X#else /* UNALIGNED_OK */
  7284. X        if (match[best_len] != scan_end ||
  7285. X            match[best_len-1] != scan_end1 || *match != scan_start)
  7286. X           continue;
  7287. X        /* It is not necessary to compare scan[1] and match[1] since they
  7288. X         * are always equal when the other bytes match, given that
  7289. X         * the hash keys are equal and that h_shift+8 <= HASH_BITS,
  7290. X         * that is, when the last byte is entirely included in the hash key.
  7291. X         * The condition is equivalent to
  7292. X         *       (HASH_BITS+2)/3 + 8 <= HASH_BITS
  7293. X         * or: HASH_BITS >= 13
  7294. X         * Also, we check for a match at best_len-1 to get rid quickly of
  7295. X         * the match with the suffix of the match made at the previous step,
  7296. X         * which is known to fail.
  7297. X         */
  7298. X#if HASH_BITS >= 13
  7299. X        len = 1;
  7300. X#else
  7301. X        len = 0;
  7302. X#endif
  7303. X        do {} while (++len < MAX_MATCH && scan[len] == match[len]);
  7304. X
  7305. X#endif /* UNALIGNED_OK */
  7306. X
  7307. X        if (len > best_len) {
  7308. X            match_start = cur_match;
  7309. X            best_len = len;
  7310. X            if (len == MAX_MATCH) break;
  7311. X#ifdef UNALIGNED_OK
  7312. X            scan_end = *(ush*)(scan+best_len-1);
  7313. X#else
  7314. X            scan_end1  = scan[best_len-1];
  7315. X            scan_end   = scan[best_len];
  7316. X#endif
  7317. X        }
  7318. X    } while (--chain_length != 0 &&
  7319. X             (cur_match = prev[cur_match & WMASK]) > limit);
  7320. X
  7321. X    return best_len;
  7322. X}
  7323. X#endif /* NO_ASM */
  7324. X
  7325. X#ifdef DEBUG
  7326. X/* ===========================================================================
  7327. X * Check that the match at match_start is indeed a match.
  7328. X */
  7329. Xlocal void check_match(start, match, length)
  7330. X    IPos start, match;
  7331. X    int length;
  7332. X{
  7333. X    /* check that the match is indeed a match */
  7334. X    if (memcmp((char*)window + match,
  7335. X                (char*)window + start, length) != EQUAL) {
  7336. X        fprintf(stderr,
  7337. X            " start %d, match %d, length %d\n",
  7338. X            start, match, length);
  7339. X        error("invalid match");
  7340. X    }
  7341. X    if (verbose > 1) {
  7342. X        fprintf(stderr,"\\[%d,%d]", start-match, length);
  7343. X        do { putc(window[start++], stderr); } while (--length != 0);
  7344. X    }
  7345. X}
  7346. X#else
  7347. X#  define check_match(start, match, length)
  7348. X#endif
  7349. X
  7350. X/* ===========================================================================
  7351. X * Fill the window when the lookahead becomes insufficient.
  7352. X * Updates strstart and lookahead, and sets eofile if end of input file.
  7353. X * IN assertion: lookahead < MIN_LOOKAHEAD && strstart + lookahead > 0
  7354. X * OUT assertion: at least one byte has been read, or eofile is set.
  7355. X */
  7356. Xlocal void fill_window()
  7357. X{
  7358. X    register unsigned n, m;
  7359. X    unsigned more = (unsigned)((ulg)2*WSIZE - (ulg)lookahead - (ulg)strstart);
  7360. X    /* Amount of free space at the end of the window. */
  7361. X
  7362. X    /* If the window is full, move the upper half to the lower one to make
  7363. X     * room in the upper half.
  7364. X     */
  7365. X    if (more == 0) {
  7366. X        /* By the IN assertion, the window is not empty so we can't confuse
  7367. X         * more == 0 with more == 64K on a 16 bit machine.
  7368. X         */
  7369. X        memcpy((char*)window, (char*)window+WSIZE, (unsigned)WSIZE);
  7370. X        match_start -= WSIZE;
  7371. X        strstart    -= WSIZE;
  7372. X        /* strstart - WSIZE = WSIZE - lookahead > WSIZE - MIN_LOOKAHEAD
  7373. X         * so we now have strstart > MAX_DIST:
  7374. X         */
  7375. X        Assert (strstart > MAX_DIST, "window slide too early");
  7376. X        block_start -= (long) WSIZE;
  7377. X
  7378. X        for (n = 0; n < HASH_SIZE; n++) {
  7379. X            m = head[n];
  7380. X            head[n] = (Pos)(m >= WSIZE ? m-WSIZE : NIL);
  7381. X        }
  7382. X        for (n = 0; n < WSIZE; n++) {
  7383. X            m = prev[n];
  7384. X            prev[n] = (Pos)(m >= WSIZE ? m-WSIZE : NIL);
  7385. X            /* If n is not on any hash chain, prev[n] is garbage but
  7386. X             * its value will never be used.
  7387. X             */
  7388. X        }
  7389. X        more = WSIZE;
  7390. X        if (verbose) putc('.', stderr);
  7391. X
  7392. X    } else if (more == (unsigned)EOF) {
  7393. X        /* Very unlikely, but possible on 16 bit machine if strstart == 0
  7394. X         * and lookahead == 1 (input done one byte at time)
  7395. X         */
  7396. X        more--;
  7397. X    }
  7398. X    n = read_buf((char*)window+strstart+lookahead, more);
  7399. X    if (n == 0 || n == (unsigned)EOF) {
  7400. X        eofile = 1;
  7401. X    } else {
  7402. X        lookahead += n;
  7403. X    }
  7404. X}
  7405. X
  7406. X/* ===========================================================================
  7407. X * Flush the current block, with given end-of-file flag.
  7408. X * IN assertion: strstart is set to the end of the current match.
  7409. X */
  7410. X#define FLUSH_BLOCK(eof) \
  7411. X   flush_block(block_start >= 0L ? (char*)&window[block_start] : (char*)NULL,\
  7412. X               (long)strstart - block_start, (eof))
  7413. X
  7414. X/* ===========================================================================
  7415. X * Processes a new input file and return its compressed length.
  7416. X */
  7417. X#ifdef NO_LAZY
  7418. Xulg deflate()
  7419. X{
  7420. X    IPos hash_head; /* head of the hash chain */
  7421. X    int flush;      /* set if current block must be flushed */
  7422. X    unsigned match_length = 0;  /* length of best match */
  7423. X
  7424. X    prev_length = MIN_MATCH-1;
  7425. X    while (lookahead != 0) {
  7426. X        /* Insert the string window[strstart .. strstart+2] in the
  7427. X         * dictionary, and set hash_head to the head of the hash chain:
  7428. X         */
  7429. X        INSERT_STRING(strstart, hash_head);
  7430. X
  7431. X        /* Find the longest match, discarding those <= prev_length.
  7432. X         * At this point we have always match_length < MIN_MATCH
  7433. X         */
  7434. X        if (hash_head != NIL && strstart - hash_head <= MAX_DIST) {
  7435. X            /* To simplify the code, we prevent matches with the string
  7436. X             * of window index 0 (in particular we have to avoid a match
  7437. X             * of the string with itself at the start of the input file).
  7438. X             */
  7439. X            match_length = longest_match (hash_head);
  7440. X            /* longest_match() sets match_start */
  7441. X            if (match_length > lookahead) match_length = lookahead;
  7442. X        }
  7443. X        if (match_length >= MIN_MATCH) {
  7444. X            check_match(strstart, match_start, match_length);
  7445. X
  7446. X            flush = ct_tally(strstart-match_start, match_length - MIN_MATCH);
  7447. X
  7448. X            lookahead -= match_length;
  7449. X            match_length--; /* string at strstart already in hash table */
  7450. X            do {
  7451. X                strstart++;
  7452. X                INSERT_STRING(strstart, hash_head);
  7453. X                /* strstart never exceeds WSIZE-MAX_MATCH, so there are
  7454. X                 * always MIN_MATCH bytes ahead. If lookahead < MIN_MATCH
  7455. X                 * these bytes are garbage, but it does not matter since the
  7456. X                 * next lookahead bytes will always be emitted as literals.
  7457. X                 */
  7458. X            } while (--match_length != 0);
  7459. X        } else {
  7460. X            /* No match, output a literal byte */
  7461. X            flush = ct_tally (0, window[strstart]);
  7462. X            lookahead--;
  7463. X        }
  7464. X        strstart++; 
  7465. X        if (flush) FLUSH_BLOCK(0), block_start = strstart;
  7466. X
  7467. X        /* Make sure that we always have enough lookahead, except
  7468. X         * at the end of the input file. We need MAX_MATCH bytes
  7469. X         * for the next match, plus MIN_MATCH bytes to insert the
  7470. X         * string following the next match.
  7471. X         */
  7472. X        while (lookahead < MIN_LOOKAHEAD && !eofile) fill_window();
  7473. X
  7474. X    }
  7475. X    return FLUSH_BLOCK(1); /* eof */
  7476. X}
  7477. X#else /* LAZY */
  7478. X/* ===========================================================================
  7479. X * Same as above, but achieves better compression. We use a lazy
  7480. X * evaluation for matches: a match is finally adopted only if there is
  7481. X * no better match at the next window position.
  7482. X */
  7483. Xulg deflate()
  7484. X{
  7485. X    IPos hash_head;          /* head of hash chain */
  7486. X    IPos prev_match;         /* previous match */
  7487. X    int flush;               /* set if current block must be flushed */
  7488. X    int match_available = 0; /* set if previous match exists */
  7489. X    register unsigned match_length = MIN_MATCH-1; /* length of best match */
  7490. X#ifdef DEBUG
  7491. X    extern ulg isize;        /* byte length of input file, for debug only */
  7492. X#endif
  7493. X
  7494. X    /* Process the input block. */
  7495. X    while (lookahead != 0) {
  7496. X        /* Insert the string window[strstart .. strstart+2] in the
  7497. X         * dictionary, and set hash_head to the head of the hash chain:
  7498. X         */
  7499. X        INSERT_STRING(strstart, hash_head);
  7500. X
  7501. X        /* Find the longest match, discarding those <= prev_length.
  7502. X         */
  7503. X        prev_length = match_length, prev_match = match_start;
  7504. X        match_length = MIN_MATCH-1;
  7505. X
  7506. X        if (hash_head != NIL && prev_length < max_lazy_match &&
  7507. X            strstart - hash_head <= MAX_DIST) {
  7508. X            /* To simplify the code, we prevent matches with the string
  7509. X             * of window index 0 (in particular we have to avoid a match
  7510. X             * of the string with itself at the start of the input file).
  7511. X             */
  7512. X            match_length = longest_match (hash_head);
  7513. X            /* longest_match() sets match_start */
  7514. X            if (match_length > lookahead) match_length = lookahead;
  7515. X            /* Ignore a length 3 match if it is too distant: */
  7516. X            if (match_length == MIN_MATCH && strstart-match_start > TOO_FAR){
  7517. X                /* If prev_match is also MIN_MATCH, match_start is garbage
  7518. X                 * but we will ignore the current match anyway.
  7519. X                 */
  7520. X                match_length--;
  7521. X            }
  7522. X        }
  7523. X        /* If there was a match at the previous step and the current
  7524. X         * match is not better, output the previous match:
  7525. X         */
  7526. X        if (prev_length >= MIN_MATCH && match_length <= prev_length) {
  7527. X
  7528. X            check_match(strstart-1, prev_match, prev_length);
  7529. X
  7530. X            flush = ct_tally(strstart-1-prev_match, prev_length - MIN_MATCH);
  7531. X
  7532. X            /* Insert in hash table all strings up to the end of the match.
  7533. X             * strstart-1 and strstart are already inserted.
  7534. X             */
  7535. X            lookahead -= prev_length-1;
  7536. X            prev_length -= 2;
  7537. X            do {
  7538. X                strstart++;
  7539. X                INSERT_STRING(strstart, hash_head);
  7540. X                /* strstart never exceeds WSIZE-MAX_MATCH, so there are
  7541. X                 * always MIN_MATCH bytes ahead. If lookahead < MIN_MATCH
  7542. X                 * these bytes are garbage, but it does not matter since the
  7543. X                 * next lookahead bytes will always be emitted as literals.
  7544. X                 */
  7545. X            } while (--prev_length != 0);
  7546. X            match_available = 0;
  7547. X            match_length = MIN_MATCH-1;
  7548. X
  7549. X        } else if (match_available) {
  7550. X            /* If there was no match at the previous position, output a
  7551. X             * single literal. If there was a match but the current match
  7552. X             * is longer, truncate the previous match to a single literal.
  7553. X             */
  7554. X            flush = ct_tally (0, window[strstart-1]);
  7555. X            Tracevv((stderr,"%c",window[strstart-1]));
  7556. X            lookahead--;
  7557. X        } else {
  7558. X            /* There is no previous match to compare with, wait for
  7559. X             * the next step to decide.
  7560. X             */
  7561. X            match_available = 1;
  7562. X            flush = 0;
  7563. X            lookahead--;
  7564. X        }
  7565. X        if (flush) FLUSH_BLOCK(0), block_start = strstart;
  7566. X        strstart++;
  7567. X        Assert (strstart <= isize && lookahead <= isize, "a bit too far");
  7568. X
  7569. X        /* Make sure that we always have enough lookahead, except
  7570. X         * at the end of the input file. We need MAX_MATCH bytes
  7571. X         * for the next match, plus MIN_MATCH bytes to insert the
  7572. X         * string following the next match.
  7573. X         */
  7574. X        while (lookahead < MIN_LOOKAHEAD && !eofile) fill_window();
  7575. X    }
  7576. X    if (match_available) ct_tally (0, window[strstart-1]);
  7577. X
  7578. X    return FLUSH_BLOCK(1); /* eof */
  7579. X}
  7580. X#endif /* LAZY */
  7581. END_OF_FILE
  7582.   if test 26162 -ne `wc -c <'deflate.c'`; then
  7583.     echo shar: \"'deflate.c'\" unpacked with wrong size!
  7584.   fi
  7585.   # end of 'deflate.c'
  7586. fi
  7587. if test -f 'msdos/tcconfig.tc.UU' -a "${1}" != "-c" ; then 
  7588.   echo shar: Will not clobber existing file \"'msdos/tcconfig.tc.UU'\"
  7589. else
  7590.   echo shar: Extracting \"'msdos/tcconfig.tc.UU'\" \(2366 characters\)
  7591.   sed "s/^X//" >'msdos/tcconfig.tc.UU' <<'END_OF_FILE'
  7592. Xbegin 666 msdos/tcconfig.tc
  7593. XM5'5R8F\@0R!#;VYF:6=U<F%T:6]N($9I;&4@&@ !#1(7 1H  @$!  (    "
  7594. XM  (  0 #  (  @ $  $   4  0  !@ !   (  $  PD  @    T  @ !  X 
  7595. XM @   !$  0 ($@ "  $ $P " !D %  "    %0 "  $ %@ "  ( %P "  $ 
  7596. XM&  "    9  !  %E  $  68  0 !9P !  %H  $  6D  0 !:@ !  %K  $ 
  7597. XM &P  0 !;0 !  %N  $  6\  0 !<  !  %Q  $  '(  0 !<P !  !T  $ 
  7598. XM 74  0 !=@ !  %W  $  7@  0 !>0 !  %Z  $  7L  0  ?  !  %]  $ 
  7599. XM 7X  0 !?P !  &   $  ((  0  A  !  &%  $  <@  0  R0 !  '*  $ 
  7600. XM ,L  0  S  !  #-  $  ,X  0 !SP !  #0  $ &=$  0!DT@ ! "#5  $ 
  7601. XM -<  0  V  !  '9  $  =H  0 !VP !  #<  $  =T  0 !W@ !  #?  $ 
  7602. XM .   0  X0 !  #B  $  2P!1                                   
  7603. XM                                                         "T!
  7604. XM@ !#.EQ40UQ)3D-,541%                                        
  7605. XM                                                            
  7606. XM                                                     "X!@ !#
  7607. XM.EQ40UQ,24(                                                 
  7608. XM                                                            
  7609. XM                                                 "\!4 !:25 N
  7610. XM4%)*                                                        
  7611. XM                                         # !!  S,@  ,0$% #(U
  7612. XM    ,@$% #$P,   ,P%_                                        
  7613. XM                                                            
  7614. XM                                                            
  7615. XM           T 1X *@                                      -0$>
  7616. XM "H                                      #8!'@ J            
  7617. XM                           W 1X *@                          
  7618. XM            . $> "H                                      #D!
  7619. XM'@ J                                       Z 1X *@          
  7620. XM                            .P$> "H                         
  7621. XM             #P!'@ J                                       ]
  7622. XM 8                                                          
  7623. XM                                                            
  7624. XM                                                       ^ 00 
  7625. XM.    #\!4                                                   
  7626. XM                                                         $ !
  7627. XM1 !#.EQ40P                                                  
  7628. XM                                 $$!4                       
  7629. XM                                                            
  7630. X9                         /__ @ :    
  7631. Xend
  7632. END_OF_FILE
  7633.   if test 2366 -ne `wc -c <'msdos/tcconfig.tc.UU'`; then
  7634.     echo shar: \"'msdos/tcconfig.tc.UU'\" unpacked with wrong size!
  7635.   else
  7636.     echo shar: Uudecoding \"'msdos/tcconfig.tc'\" \(1690 characters\)
  7637.     cat msdos/tcconfig.tc.UU | uudecode
  7638.     if test 1690 -ne `wc -c <'msdos/tcconfig.tc'`; then
  7639.       echo shar: \"'msdos/tcconfig.tc'\" uudecoded with wrong size!
  7640.     else
  7641.       rm msdos/tcconfig.tc.UU
  7642.     fi
  7643.   fi
  7644.   # end of 'msdos/tcconfig.tc.UU'
  7645. fi
  7646. if test -f 'os2/os2zip.c.UU' -a "${1}" != "-c" ; then 
  7647.   echo shar: Will not clobber existing file \"'os2/os2zip.c.UU'\"
  7648. else
  7649.   echo shar: Extracting \"'os2/os2zip.c.UU'\" \(28901 characters\)
  7650.   sed "s/^X//" >'os2/os2zip.c.UU' <<'END_OF_FILE'
  7651. Xbegin 666 os2/os2zip.c
  7652. XM+RH-"B J($ H(RED:7(N8R Q+C0@.#<O,3$O,#8@4'5B;&EC($1O;6%I;BX-
  7653. XM"B J#0H@*B @02!P=6)L:6,@9&]M86EN(&EM<&QE;65N=&%T:6]N(&]F($)3
  7654. XM1"!D:7)E8W1O<GD@<F]U=&EN97,@9F]R#0H@*B @35,M1$]3+B @5W)I='1E
  7655. XM;B!B>2!-:6-H865L(%)E;F1E;&P@*'MU=6YE="QU=&%I?6UI8VAA96Q 9V%R
  7656. XM9FEE;&0I+ T*("H@($%U9W5S=" Q.#DW#0H@*B @4&]R=&5D('1O($]3+S(@
  7657. XM8GD@2V%I(%5W92!2;VUM96P-"B J("!$96-E;6)E<B Q.3@Y+"!&96)R=6%R
  7658. XM>2 Q.3DP#0H@*B @0VAA;F=E(&9O<B!(4$93('-U<'!O<G0L($]C=&]B97(@
  7659. XM,3DY, T*("HO#0H-"B\J(&1O97,@86QS;R!C;VYT86EN($5!(&%C8V5S<R!C
  7660. XM;V1E(&9O<B!U<V4@:6X@6DE0("HO#0H-"@T*(VEF9&5F(%]?14U87U\-"B-D
  7661. XM969I;F4@7U\S,D))5%]?#0HC96YD:68-"@T*(VEN8VQU9&4@(GII<"YH(@T*
  7662. XM#0HC:6YC;'5D92 \<W1D;&EB+F@^#0HC:6YC;'5D92 \=&EM92YH/@T*(VEN
  7663. XM8VQU9&4@/&-T>7!E+F@^#0H-"B-I9F1E9B!?7U=!5$-/34-?7PT*(VEN8VQU
  7664. XM9&4@/&UA;&QO8RYH/@T*=6YS:6=N960@8VAA<B!?7VYE87(@7V]S;6]D92 ]
  7665. XM($]3,E]-3T1%.PT*(V5N9&EF#0H-"B-D969I;F4@24Y#3%].3U!-#0HC9&5F
  7666. XM:6YE($E.0TQ?1$]33DQ3#0HC9&5F:6YE($E.0TQ?1$]315)23U)3#0HC:6YC
  7667. XM;'5D92 \;W,R+F@^#0H-"B-I;F-L=61E(")O<S)Z:7 N:"(-"@T*#0HC9&5F
  7668. XM:6YE($5!240@(" @(#!X,# P.0T*#0H-"B-I9F1E9B!?7S,R0DE47U\-"B-D
  7669. XM969I;F4@1&]S1FEN9$9I<G-T*' Q+"!P,BP@<#,L(' T+"!P-2P@<#8I(%P-
  7670. XM"B @(" @(" @1&]S1FEN9$9I<G-T*' Q+"!P,BP@<#,L(' T+"!P-2P@<#8L
  7671. XM(#$I#0HC96QS90T*(V1E9FEN92!$;W-1=65R>4-U<G)E;G1$:7-K($1O<U%#
  7672. XM=7)$:7-K#0HC9&5F:6YE($1O<U%U97)Y1E-!='1A8V@H<#$L(' R+"!P,RP@
  7673. XM<#0L(' U*2!<#0H@(" @(" @($1O<U%&4T%T=&%C:"AP,2P@<#(L(' S+"!P
  7674. XM-"P@<#4L(# I#0HC9&5F:6YE($1O<U%U97)Y4&%T:$EN9F\H<#$L(' R+"!P
  7675. XM,RP@<#0I(%P-"B @(" @(" @1&]S45!A=&A);F9O*' Q+"!P,BP@<#,L(' T
  7676. XM+" P*0T*(V1E9FEN92!$;W-39710871H26YF;RAP,2P@<#(L(' S+"!P-"P@
  7677. XM<#4I(%P-"B @(" @(" @1&]S4V5T4&%T:$EN9F\H<#$L(' R+"!P,RP@<#0L
  7678. XM(' U+" P*0T*(V1E9FEN92!$;W-%;G5M071T<FEB=71E*' Q+"!P,BP@<#,L
  7679. XM(' T+"!P-2P@<#8L(' W*2!<#0H@(" @(" @($1O<T5N=6U!='1R:6)U=&4H
  7680. XM<#$L(' R+"!P,RP@<#0L(' U+"!P-BP@<#<L(# I#0HC9&5F:6YE($1O<T9I
  7681. XM;F1&:7)S="AP,2P@<#(L(' S+"!P-"P@<#4L(' V*2!<#0H@(" @(" @($1O
  7682. XM<T9I;F1&:7)S="AP,2P@<#(L(' S+"!P-"P@<#4L(' V+" P*0T*(V1E9FEN
  7683. XM92!$;W--87!#87-E($1O<T-A<V5-87 -"B-E;F1I9@T*#0H-"B-I9FYD968@
  7684. XM551)3 T*#0IE>'1E<FX@:6YT(&YO:7-Y.PT*#0HC:69N9&5F(%-?249-5 T*
  7685. XM(V1E9FEN92!37TE&350@,'A&,# P#0HC96YD:68-"@T*<W1A=&EC(&EN="!A
  7686. XM='1R:6)U=&5S(#T@05]$25(@?"!!7TA)1$1%3B!\($%?4UE35$5-.PT*#0IS
  7687. XM=&%T:6,@8VAA<B J9V5T9&ER96YT*&-H87(@*BD[#0IS=&%T:6,@=F]I9"!F
  7688. XM<F5E7V1I<F-O;G1E;G1S*'-T<G5C="!?9&ER8V]N=&5N=',@*BD[#0H-"B-I
  7689. XM9F1E9B!?7S,R0DE47U\-"G-T871I8R!(1$E2(&AD:7([#0IS=&%T:6,@54Q/
  7690. XM3D<@8V]U;G0[#0IS=&%T:6,@1DE,149)3D1"548S(&9I;F0[#0HC96QS90T*
  7691. XM<W1A=&EC($A$25(@:&1I<CL-"G-T871I8R!54TA/4E0@8V]U;G0[#0IS=&%T
  7692. XM:6,@1DE,149)3D1"548@9FEN9#L-"B-E;F1I9@T*#0H-"D1)4B J;W!E;F1I
  7693. XM<BAC:&%R("IN86UE*0T*>PT*("!S=')U8W0@<W1A="!S=&%T8CL-"B @1$E2
  7694. XM("ID:7)P.PT*("!C:&%R(&,[#0H@(&-H87(@*G,[#0H@('-T<G5C="!?9&ER
  7695. XM8V]N=&5N=',@*F1P.PT*("!C:&%R(&YB=69;34%84$%42$Q%3B K(#%=.PT*
  7696. XM("!I;G0@;&5N.PT*#0H@('-T<F-P>2AN8G5F+"!N86UE*3L-"B @;&5N(#T@
  7697. XM<W1R;&5N("AN8G5F*3L-"B @<R ](&YB=68@*R!L96X[#0H-"B @:68@*" H
  7698. XM*&,@/2!N8G5F6W-T<FQE;BAN8G5F*2 M(#%=*2 ]/2 G7%PG('Q\(&,@/3T@
  7699. XM)R\G*2 F)@T*(" @(" @("AS=')L96XH;F)U9BD@/B Q*2 I#0H@('L-"B @
  7700. XM("!N8G5F6W-T<FQE;BAN8G5F*2 M(#%=(#T@,#L-"@T*(" @(&EF("@@;F)U
  7701. XM9EMS=')L96XH;F)U9BD@+2 Q72 ]/2 G.B<@*0T*(" @(" @<W1R8V%T*&YB
  7702. XM=68L(")<7"XB*3L-"B @?0T*("!E;'-E#0H@(" @:68@*"!N8G5F6W-T<FQE
  7703. XM;BAN8G5F*2 M(#%=(#T]("<Z)R I#0H@(" @("!S=')C870H;F)U9BP@(BXB
  7704. XM*3L-"@T*("!I9B H<W1A="AN8G5F+" F<W1A=&(I(#P@,"!\?" H<W1A=&(N
  7705. XM<W1?;6]D92 F(%-?249-5"D@(3T@4U])1D1)4BD-"B @("!R971U<FX@3E5,
  7706. XM3#L-"@T*("!I9B H("AD:7)P(#T@;6%L;&]C*'-I>F5O9BA$25(I*2D@/3T@
  7707. XM3E5,3" I#0H@(" @<F5T=7)N($Y53$P[#0H-"B @:68@*"!N8G5F6W-T<FQE
  7708. XM;BAN8G5F*2 M(#%=(#T]("<N)R I#0H@(" @<W1R8W!Y*&YB=68@*R!S=')L
  7709. XM96XH;F)U9BD@+2 Q+" B*BXJ(BD[#0H@(&5L<V4-"B @("!I9B H("@H8R ]
  7710. XM(&YB=69;<W1R;&5N*&YB=68I("T@,5TI(#T]("=<7"<@?'P@8R ]/2 G+R<I
  7711. XM("8F#0H@(" @(" @(" H<W1R;&5N*&YB=68I(#T](#$I("D-"B @(" @('-T
  7712. XM<F-A="AN8G5F+" B*BXJ(BD[#0H@(" @96QS90T*(" @(" @<W1R8V%T*&YB
  7713. XM=68L(")<7"HN*B(I.PT*#0H@(&1I<G @+3X@9&1?;&]C(#T@,#L-"B @9&ER
  7714. XM<" M/B!D9%]C;VYT96YT<R ](&1I<G @+3X@9&1?8W @/2!.54Q,.PT*#0H@
  7715. XM(&EF("@H<R ](&=E=&1I<F5N="AN8G5F*2D@/3T@3E5,3"D-"B @("!R971U
  7716. XM<FX@9&ER<#L-"@T*("!D;PT*("![#0H@(" @:68@*"@H9' @/2!M86QL;V,H
  7717. XM<VEZ96]F*'-T<G5C="!?9&ER8V]N=&5N=',I*2D@/3T@3E5,3"D@?'P-"B @
  7718. XM(" @(" @*"AD<" M/B!?9%]E;G1R>2 ](&UA;&QO8RAS=')L96XH<RD@*R Q
  7719. XM*2D@/3T@3E5,3"D@(" @(" I#0H@(" @>PT*(" @(" @:68@*&1P*0T*(" @
  7720. XM(" @("!F<F5E*&1P*3L-"B @(" @(&9R965?9&ER8V]N=&5N=',H9&ER<" M
  7721. XM/B!D9%]C;VYT96YT<RD[#0H-"B @(" @(')E='5R;B!.54Q,.PT*(" @('T-
  7722. XM"@T*(" @(&EF("AD:7)P("T^(&1D7V-O;G1E;G1S*0T*(" @('L-"B @(" @
  7723. XM(&1I<G @+3X@9&1?8W @+3X@7V1?;F5X=" ](&1P.PT*(" @(" @9&ER<" M
  7724. XM/B!D9%]C<" ](&1I<G @+3X@9&1?8W @+3X@7V1?;F5X=#L-"B @("!]#0H@
  7725. XM(" @96QS90T*(" @(" @9&ER<" M/B!D9%]C;VYT96YT<R ](&1I<G @+3X@
  7726. XM9&1?8W @/2!D<#L-"@T*(" @('-T<F-P>2AD<" M/B!?9%]E;G1R>2P@<RD[
  7727. XM#0H@(" @9' @+3X@7V1?;F5X=" ]($Y53$P[#0H-"B @("!D<" M/B!?9%]S
  7728. XM:7IE(#T@9FEN9"YC8D9I;&4[#0H@(" @9' @+3X@7V1?;6]D92 ](&9I;F0N
  7729. XM871T<D9I;&4[#0H@(" @9' @+3X@7V1?=&EM92 ]("HH=6YS:6=N960@*BD@
  7730. XM)BAF:6YD+F9T:6UE3&%S=%=R:71E*3L-"B @("!D<" M/B!?9%]D871E(#T@
  7731. XM*BAU;G-I9VYE9" J*2 F*&9I;F0N9F1A=&5,87-T5W)I=&4I.PT*("!]#0H@
  7732. XM('=H:6QE("@H<R ](&=E=&1I<F5N="A.54Q,*2D@(3T@3E5,3"D[#0H-"B @
  7733. XM9&ER<" M/B!D9%]C<" ](&1I<G @+3X@9&1?8V]N=&5N=',[#0H-"B @<F5T
  7734. XM=7)N(&1I<G [#0I]#0H-"@T*=F]I9"!C;&]S961I<BA$25(@*B!D:7)P*0T*
  7735. XM>PT*("!F<F5E7V1I<F-O;G1E;G1S*&1I<G @+3X@9&1?8V]N=&5N=',I.PT*
  7736. XM("!F<F5E*&1I<G I.PT*?0T*#0H-"G-T<G5C="!D:7)E8W0@*G)E861D:7(H
  7737. XM1$E2("H@9&ER<"D-"GL-"B @<W1A=&EC('-T<G5C="!D:7)E8W0@9' [#0H-
  7738. XM"B @:68@*&1I<G @+3X@9&1?8W @/3T@3E5,3"D-"B @("!R971U<FX@3E5,
  7739. XM3#L-"@T*("!D<"YD7VYA;6QE;B ](&1P+F1?<F5C;&5N(#T-"B @("!S=')L
  7740. XM96XH<W1R8W!Y*&1P+F1?;F%M92P@9&ER<" M/B!D9%]C<" M/B!?9%]E;G1R
  7741. XM>2DI.PT*#0H@(&1P+F1?:6YO(#T@,#L-"@T*("!D<"YD7W-I>F4@/2!D:7)P
  7742. XM("T^(&1D7V-P("T^(%]D7W-I>F4[#0H@(&1P+F1?;6]D92 ](&1I<G @+3X@
  7743. XM9&1?8W @+3X@7V1?;6]D93L-"B @9' N9%]T:6UE(#T@9&ER<" M/B!D9%]C
  7744. XM<" M/B!?9%]T:6UE.PT*("!D<"YD7V1A=&4@/2!D:7)P("T^(&1D7V-P("T^
  7745. XM(%]D7V1A=&4[#0H-"B @9&ER<" M/B!D9%]C<" ](&1I<G @+3X@9&1?8W @
  7746. XM+3X@7V1?;F5X=#L-"B @9&ER<" M/B!D9%]L;V,K*SL-"@T*("!R971U<FX@
  7747. XM)F1P.PT*?0T*#0H-"G9O:60@<V5E:V1I<BA$25(@*B!D:7)P+"!L;VYG(&]F
  7748. XM9BD-"GL-"B @;&]N9R!I(#T@;V9F.PT*("!S=')U8W0@7V1I<F-O;G1E;G1S
  7749. XM("ID<#L-"@T*("!I9B H;V9F(#X](# I#0H@('L-"B @("!F;W(@*&1P(#T@
  7750. XM9&ER<" M/B!D9%]C;VYT96YT<SL@+2UI(#X](# @)B8@9' [(&1P(#T@9' @
  7751. XM+3X@7V1?;F5X="D[#0H-"B @("!D:7)P("T^(&1D7VQO8R ](&]F9B M("AI
  7752. XM("L@,2D[#0H@(" @9&ER<" M/B!D9%]C<" ](&1P.PT*("!]#0I]#0H-"@T*
  7753. XM;&]N9R!T96QL9&ER*$1)4B J(&1I<G I#0I[#0H@(')E='5R;B!D:7)P("T^
  7754. XM(&1D7VQO8SL-"GT-"@T*#0IS=&%T:6,@=F]I9"!F<F5E7V1I<F-O;G1E;G1S
  7755. XM*'-T<G5C="!?9&ER8V]N=&5N=',@*B!D<"D-"GL-"B @<W1R=6-T(%]D:7)C
  7756. XM;VYT96YT<R J;V1P.PT*#0H@('=H:6QE("AD<"D-"B @>PT*(" @(&EF("AD
  7757. XM<" M/B!?9%]E;G1R>2D-"B @(" @(&9R964H9' @+3X@7V1?96YT<GDI.PT*
  7758. XM#0H@(" @9' @/2 H;V1P(#T@9' I("T^(%]D7VYE>'0[#0H@(" @9G)E92AO
  7759. XM9' I.PT*("!]#0I]#0H-"@T*<W1A=&EC(&-H87(@*F=E=&1I<F5N="AC:&%R
  7760. XM("ID:7(I#0I[#0H@(&EN="!D;VYE.PT*("!S=&%T:6,@:6YT(&QO=V5R.PT*
  7761. XM#0H@(&EF("AD:7(@(3T@3E5,3"D-"B @>R @(" @(" @(" @(" @(" @(" @
  7762. XM(" @(" @(" @(" @(" @("\J(&=E="!F:7)S="!E;G1R>2 J+PT*(" @(&AD
  7763. XM:7(@/2!(1$E27T-214%413L-"B @("!C;W5N=" ](#$[#0H@(" @9&]N92 ]
  7764. XM($1O<T9I;F1&:7)S="AD:7(L("9H9&ER+"!A='1R:6)U=&5S+" F9FEN9"P@
  7765. XM<VEZ96]F*&9I;F0I+" F8V]U;G0I.PT*(" @(&QO=V5R(#T@27-&:6QE4WES
  7766. XM=&5M1D%4*&1I<BD[#0H@('T-"B @96QS92 @(" @(" @(" @(" @(" @(" @
  7767. XM(" @(" @(" @(" @("\J(&=E="!N97AT(&5N=')Y("HO#0H@(" @9&]N92 ]
  7768. XM($1O<T9I;F1.97AT*&AD:7(L("9F:6YD+"!S:7IE;V8H9FEN9"DL("9C;W5N
  7769. XM="D[#0H-"B @:68@*&1O;F4@/3T@,"D-"B @>PT*(" @(&EF("@@;&]W97(@
  7770. XM*0T*(" @(" @4W1R:6YG3&]W97(H9FEN9"YA8VA.86UE*3L-"B @("!R971U
  7771. XM<FX@9FEN9"YA8VA.86UE.PT*("!]#0H@(&5L<V4-"B @>PT*(" @($1O<T9I
  7772. XM;F1#;&]S92AH9&ER*3L-"B @("!R971U<FX@3E5,3#L-"B @?0T*?0T*#0H-
  7773. XM"B\J($9!5" O($A01E,@9&5T96-T:6]N("HO#0H-"FEN="!)<T9I;&53>7-T
  7774. XM96U&050H8VAA<B J9&ER*0T*>PT*("!S=&%T:6,@55-(3U)4(&Y,87-T1')I
  7775. XM=F4@/2 M,2P@;E)E<W5L=#L-"B @54Q/3D<@;$UA<#L-"B @0EE412!B1&%T
  7776. XM85LV-%TL(&).86UE6S-=.PT*(VEF9&5F(%]?,S)"251?7PT*("!53$].1R!N
  7777. XM1')I=F4L(&-B1&%T83L-"B @4$9344)51D9%4C(@<$1A=&$@/2 H4$9344)5
  7778. XM1D9%4C(I(&)$871A.PT*(V5L<V4-"B @55-(3U)4(&Y$<FEV92P@8V)$871A
  7779. XM.PT*("!01E-10E5&1D52('!$871A(#T@*%!&4U%"549&15(I(&)$871A.PT*
  7780. XM(V5N9&EF#0H-"B @:68@*"!?;W-M;V1E(#T]($1/4U]-3T1%("D-"B @("!R
  7781. XM971U<FX@5%)513L-"B @96QS90T*("![#0H@(" @+RH@5V4@<V5P87)A=&4@
  7782. XM1D%4(&%N9"!(4$93*V]T:&5R(&9I;&4@<WES=&5M<R!H97)E+@T*(" @(" @
  7783. XM(&%T('1H92!M;VUE;G0@22!C;VYS:61E<B!O=&AE<B!S>7-T96US('1O(&)E
  7784. XM('-I;6EL87(@=&\@2%!&4RP-"B @(" @("!I+F4N('-U<'!O<G0@;&]N9R!F
  7785. XM:6QE(&YA;65S(&%N9"!B965I;F<@8V%S92!S96YS:71I=F4@*B\-"@T*(" @
  7786. XM(&EF("@@:7-A;'!H82AD:7);,%TI("8F("AD:7);,5T@/3T@)SHG*2 I#0H@
  7787. XM(" @("!N1')I=F4@/2!T;U]U<"AD:7);,%TI("T@)T G.PT*(" @(&5L<V4-
  7788. XM"B @(" @($1O<U%U97)Y0W5R<F5N=$1I<VLH)FY$<FEV92P@)FQ-87 I.PT*
  7789. XM#0H@(" @:68@*"!N1')I=F4@/3T@;DQA<W1$<FEV92 I#0H@(" @("!R971U
  7790. XM<FX@;E)E<W5L=#L-"@T*(" @(&).86UE6S!=(#T@*&-H87(I("AN1')I=F4@
  7791. XM*R G0"<I.PT*(" @(&).86UE6S%=(#T@)SHG.PT*(" @(&).86UE6S)=(#T@
  7792. XM,#L-"@T*(" @(&Y,87-T1')I=F4@/2!N1')I=F4[#0H@(" @8V)$871A(#T@
  7793. XM<VEZ96]F*&)$871A*3L-"@T*(" @(&EF("@@(41O<U%U97)Y1E-!='1A8V@H
  7794. XM8DYA;64L(# L($9304E,7U%515)93D%-12P@*%!63TE$*2!P1&%T82P@)F-B
  7795. XM1&%T82D@*0T*(" @(" @;E)E<W5L=" ]("%S=')C;7 H<$1A=&$@+3X@<WI&
  7796. XM4T1.86UE("L@<$1A=&$@+3X@8V).86UE+" B1D%4(BD[#0H@(" @96QS90T*
  7797. XM(" @(" @;E)E<W5L=" ]($9!3%-%.PT*#0H@(" @+RH@16YD(&]F('1H:7,@
  7798. XM=6=L>2!C;V1E("HO#0H@(" @<F5T=7)N(&Y297-U;'0[#0H@('T-"GT-"@T*
  7799. XM#0HO*B!A8V-E<W,@;6]D92!B:71S(&%N9"!T:6UE('-T86UP("HO#0H-"FEN
  7800. XM="!'971&:6QE36]D92AC:&%R("IN86UE*0T*>PT*(VEF9&5F(%]?,S)"251?
  7801. XM7PT*("!&24Q%4U1!5%53,R!F<SL-"B @<F5T=7)N($1O<U%U97)Y4&%T:$EN
  7802. XM9F\H;F%M92P@,2P@)F9S+"!S:7IE;V8H9G,I*2 _("TQ(#H@9G,N871T<D9I
  7803. XM;&4[#0HC96QS90T*("!54TA/4E0@;6]D93L-"B @<F5T=7)N($1O<U%&:6QE
  7804. XM36]D92AN86UE+" F;6]D92P@,$PI(#\@+3$@.B!M;V1E.PT*(V5N9&EF#0I]
  7805. XM#0H-"FQO;F<@1V5T1FEL951I;64H8VAA<B J;F%M92D-"GL-"B-I9F1E9B!?
  7806. XM7S,R0DE47U\-"B @1DE,15-405154S,@9G,[#0HC96QS90T*("!&24Q%4U1!
  7807. XM5%53(&9S.PT*(V5N9&EF#0H@(%532$]25"!N1&%T92P@;E1I;64[#0H-"B @
  7808. XM:68@*"!$;W-1=65R>5!A=&A);F9O*&YA;64L(#$L("A00EE412D@)F9S+"!S
  7809. XM:7IE;V8H9G,I*2 I#0H@(" @<F5T=7)N("TQ.PT*#0H@(&Y$871E(#T@*B H
  7810. XM55-(3U)4("HI("9F<RYF9&%T94QA<W17<FET93L-"B @;E1I;64@/2 J("A5
  7811. XM4TA/4E0@*BD@)F9S+F9T:6UE3&%S=%=R:71E.PT*#0H@(')E='5R;B H*%5,
  7812. XM3TY'*2!N1&%T92D@/#P@,38@?"!N5&EM93L-"GT-"@T*=F]I9"!3971&:6QE
  7813. XM5&EM92AC:&%R("IP871H+"!L;VYG('-T86UP*0T*>PT*("!&24Q%4U1!5%53
  7814. XM(&9S.PT*("!54TA/4E0@9F0L(&9T.PT*("!54TA/4E0@;DQE;F=T:#L-"B @
  7815. XM8VAA<B!S>DYA;65;0T-(34%84$%42%T[#0H-"B @:68@*"!$;W-1=65R>5!A
  7816. XM=&A);F9O*'!A=&@L($9)3%]35$%.1$%21"P@*%!"651%*2 F9G,L('-I>F5O
  7817. XM9BAF<RDI("D-"B @("!R971U<FX[#0H-"B @9F0@/2 H55-(3U)4*2 H<W1A
  7818. XM;7 @/CX@,38I.PT*("!F=" ]("A54TA/4E0I('-T86UP.PT*("!F<RYF9&%T
  7819. XM94QA<W17<FET92 ](&9S+F9D871E0W)E871I;VX@/2 J("A&1$%412 J*2 F
  7820. XM9F0[#0H@(&9S+F9T:6UE3&%S=%=R:71E(#T@9G,N9G1I;65#<F5A=&EO;B ]
  7821. XM("H@*$9424U%("HI("9F=#L-"@T*("!$;W-39710871H26YF;RAP871H+"!&
  7822. XM24Q?4U1!3D1!4D0L("A00EE412D@)F9S+"!S:7IE;V8H9G,I+" P*3L-"GT-
  7823. XM"@T*#0HO*B!&050@+R!(4$93(&YA;64@8V]N=F5R<VEO;B!S='5F9B J+PT*
  7824. XM#0II;G0@27-&:6QE3F%M959A;&ED*&-H87(@*FYA;64I#0I[#0H@($A&24Q%
  7825. XM(&AF.PT*(VEF9&5F(%]?,S)"251?7PT*("!53$].1R!U06-T:6]N.PT*(V5L
  7826. XM<V4-"B @55-(3U)4('5!8W1I;VX[#0HC96YD:68-"@T*("!S=VET8V@H($1O
  7827. XM<T]P96XH;F%M92P@)FAF+" F=4%C=&EO;BP@,"P@,"P@1DE,15]/4$5.+ T*
  7828. XM(" @(" @(" @(" @(" @(" @3U!%3E]!0T-%4U-?4D5!1$].3%D@?"!/4$5.
  7829. XM7U-(05)%7T1%3EE.3TY%+" P*2 I#0H@('L-"B @8V%S92!%4E)/4E])3E9!
  7830. XM3$E$7TY!344Z#0H@(&-A<V4@15)23U)?1DE,14Y!345?15A#141?4D%.1T4Z
  7831. XM#0H@(" @<F5T=7)N($9!3%-%.PT*("!C87-E($Y/7T524D]2.@T*(" @($1O
  7832. XM<T-L;W-E*&AF*3L-"B @9&5F875L=#H-"B @("!R971U<FX@5%)513L-"B @
  7833. XM?0T*?0T*#0H-"G9O:60@0VAA;F=E3F%M949O<D9!5"AC:&%R("IN86UE*0T*
  7834. XM>PT*("!C:&%R("IS<F,L("ID<W0L("IN97AT+" J<'1R+" J9&]T+" J<W1A
  7835. XM<G0[#0H@('-T871I8R!C:&%R(&EN=F%L:61;72 ]("(Z.RP]*UPB6UT\/GP@
  7836. XM7'0B.PT*#0H@(&EF("@@:7-A;'!H82AN86UE6S!=*2 F)B H;F%M95LQ72 ]
  7837. XM/2 G.B<I("D-"B @("!S=&%R=" ](&YA;64@*R R.PT*("!E;'-E#0H@(" @
  7838. XM<W1A<G0@/2!N86UE.PT*#0H@('-R8R ](&1S=" ]('-T87)T.PT*("!I9B H
  7839. XM("@J<W)C(#T]("<O)RD@?'P@*"IS<F,@/3T@)UQ<)RD@*0T*(" @('-R8RLK
  7840. XM+"!D<W0K*SL-"@T*("!W:&EL92 H("IS<F,@*0T*("![#0H@(" @9F]R("@@
  7841. XM;F5X=" ]('-R8SL@*FYE>'0@)B8@*"IN97AT("$]("<O)RD@)B8@*"IN97AT
  7842. XM("$]("=<7"<I.R!N97AT*RL@*3L-"@T*(" @(&9O<B H('!T<B ]('-R8RP@
  7843. XM9&]T(#T@3E5,3#L@<'1R(#P@;F5X=#L@<'1R*RL@*0T*(" @(" @:68@*" J
  7844. XM<'1R(#T]("<N)R I#0H@(" @("![#0H@(" @(" @(&1O=" ]('!T<CL@+RH@
  7845. XM<F5M96UB97(@;&%S="!D;W0@*B\-"B @(" @(" @*G!T<B ]("=?)SL-"B @
  7846. XM(" @('T-"@T*(" @(&EF("@@9&]T(#T]($Y53$P@*0T*(" @(" @9F]R("@@
  7847. XM<'1R(#T@<W)C.R!P='(@/"!N97AT.R!P='(K*R I#0H@(" @(" @(&EF("@@
  7848. XM*G!T<B ]/2 G7R<@*0T*(" @(" @(" @(&1O=" ]('!T<CL@+RH@<F5M96UB
  7849. XM97(@;&%S="!?(&%S(&EF(&ET('=E<F4@82!D;W0@*B\-"@T*(" @(&EF("@@
  7850. XM9&]T("8F("AD;W0@/B!S<F,I("8F#0H@(" @(" @(" H*&YE>'0@+2!D;W0@
  7851. XM/#T@-"D@?'P-"B @(" @(" @(" H*&YE>'0@+2!S<F,@/B X*2 F)B H9&]T
  7852. XM("T@<W)C(#X@,RDI*2 I#0H@(" @>PT*(" @(" @:68@*"!D;W0@*0T*(" @
  7853. XM(" @(" J9&]T(#T@)RXG.PT*#0H@(" @("!F;W(@*"!P='(@/2!S<F,[("AP
  7854. XM='(@/"!D;W0I("8F("@H<'1R("T@<W)C*2 \(#@I.R!P='(K*R I#0H@(" @
  7855. XM(" @("ID<W0K*R ]("IP='([#0H-"B @(" @(&9O<B H('!T<B ](&1O=#L@
  7856. XM*'!T<B \(&YE>'0I("8F("@H<'1R("T@9&]T*2 \(#0I.R!P='(K*R I#0H@
  7857. XM(" @(" @("ID<W0K*R ]("IP='([#0H@(" @?0T*(" @(&5L<V4-"B @("![
  7858. XM#0H@(" @("!I9B H(&1O=" F)B H;F5X=" M('-R8R ]/2 Q*2 I#0H@(" @
  7859. XM(" @("ID;W0@/2 G+B<[(" @(" @(" @(" O*B!S<&5C:6%L(&-A<V4Z("(N
  7860. XM(B!A<R!A('!A=&@@8V]M<&]N96YT("HO#0H-"B @(" @(&9O<B H('!T<B ]
  7861. XM('-R8SL@*'!T<B \(&YE>'0I("8F("@H<'1R("T@<W)C*2 \(#@I.R!P='(K
  7862. XM*R I#0H@(" @(" @("ID<W0K*R ]("IP='([#0H@(" @?0T*#0H@(" @*F1S
  7863. XM="LK(#T@*FYE>'0[("\J(&5I=&AE<B G+R<@;W(@," J+PT*#0H@(" @:68@
  7864. XM*" J;F5X=" I#0H@(" @>PT*(" @(" @<W)C(#T@;F5X=" K(#$[#0H-"B @
  7865. XM(" @(&EF("@@*G-R8R ]/2 P("D@+RH@:&%N9&QE('1R86EL:6YG("<O)R!O
  7866. XM;B!D:7)S("$@*B\-"B @(" @(" @*F1S=" ](# [#0H@(" @?0T*(" @(&5L
  7867. XM<V4-"B @(" @(&)R96%K.PT*("!]#0H-"B @9F]R("@@<W)C(#T@<W1A<G0[
  7868. XM("IS<F,@(3T@,#L@*RMS<F,@*0T*(" @(&EF("@@*'-T<F-H<BAI;G9A;&ED
  7869. XM+" J<W)C*2 A/2!.54Q,*2!\?" H*G-R8R ]/2 G("<I("D-"B @(" @("IS
  7870. XM<F,@/2 G7R<[#0I]#0H-"@T*+RH@+DQ/3D=.04U%($5!(&-O9&4@*B\-"@T*
  7871. XM='EP961E9B!S=')U8W0-"GL-"B @54Q/3D<@8V),:7-T.R @(" @(" @(" @
  7872. XM(" @("\J(&QE;F=T:"!O9B!V86QU92 K(#(R("HO#0HC:69D968@7U\S,D))
  7873. XM5%]?#0H@(%5,3TY'(&].97AT.PT*(V5N9&EF#0H@($)95$4@9D5!.R @(" @
  7874. XM(" @(" @(" @(" @(" O*B P("HO#0H@($)95$4@8V).86UE.R @(" @(" @
  7875. XM(" @(" @(" O*B!L96YG=&@@;V8@(BY,3TY'3D%-12(@/2 Y("HO#0H@(%53
  7876. XM2$]25"!C8E9A;'5E.R @(" @(" @(" @(" O*B!L96YG=&@@;V8@=F%L=64@
  7877. XM*R T("HO#0H@($)95$4@<WI.86UE6S$P73L@(" @(" @(" @(" O*B B+DQ/
  7878. XM3D=.04U%(B J+PT*("!54TA/4E0@96%4>7!E.R @(" @(" @(" @(" @+RH@
  7879. XM,'A&1D9$(&9O<B!L96YG=&@M<')E8V5D960@05-#24D@*B\-"B @55-(3U)4
  7880. XM(&5A4VEZ93L@(" @(" @(" @(" @("\J(&QE;F=T:"!O9B!V86QU92 J+PT*
  7881. XM("!"651%('-Z5F%L=65;0T-(34%84$%42%T[#0I]#0I&14%,4U0[#0H-"G1Y
  7882. XM<&5D968@<W1R=6-T#0I[#0H@(%5,3TY'(&-B3&ES=#L-"B-I9F1E9B!?7S,R
  7883. XM0DE47U\-"B @54Q/3D<@;TYE>'0[#0HC96YD:68-"B @0EE412!C8DYA;64[
  7884. XM#0H@($)95$4@<WI.86UE6S$P73L@(" @(" @(" @(" O*B B+DQ/3D=.04U%
  7885. XM(B J+PT*?0T*1T5!3%-4.PT*#0H-"F-H87(@*D=E=$QO;F=.86UE14$H8VAA
  7886. XM<B J;F%M92D-"GL-"B @14%/4"!E86]P.PT*("!'14%,4U0@9V5A;'-T.PT*
  7887. XM("!S=&%T:6,@1D5!3%-4(&9E86QS=#L-"@T*("!I9B H(%]O<VUO9&4@/3T@
  7888. XM1$]37TU/1$4@*0T*(" @(')E='5R;B!.54Q,.PT*#0H@(&5A;W N9G!'14%,
  7889. XM:7-T(#T@*%!'14%,25-4*2 F9V5A;'-T.PT*("!E86]P+F9P1D5!3&ES=" ]
  7890. XM("A01D5!3$E35"D@)F9E86QS=#L-"B @96%O<"YO17)R;W(@/2 P.PT*#0H@
  7891. XM('-T<F-P>2AG96%L<W0N<WI.86UE+" B+DQ/3D=.04U%(BD[#0H@(&=E86QS
  7892. XM="YC8DYA;64@(#T@*$)95$4I('-T<FQE;BAG96%L<W0N<WI.86UE*3L-"B-I
  7893. XM9F1E9B!?7S,R0DE47U\-"B @9V5A;'-T+F].97AT(" @/2 P.PT*(V5N9&EF
  7894. XM#0H-"B @9V5A;'-T+F-B3&ES=" @/2!S:7IE;V8H9V5A;'-T*3L-"B @9F5A
  7895. XM;'-T+F-B3&ES=" @/2!S:7IE;V8H9F5A;'-T*3L-"@T*("!I9B H($1O<U%U
  7896. XM97)Y4&%T:$EN9F\H;F%M92P@1DE,7U%515)914%31E)/34Q)4U0L#0H@(" @
  7897. XM(" @(" @(" @(" @(" @(" @(" H4$)95$4I("9E86]P+"!S:7IE;V8H96%O
  7898. XM<"DI("D-"B @("!R971U<FX@3E5,3#L-"@T*("!I9B H(&9E86QS="YC8E9A
  7899. XM;'5E(#X@-" F)B!F96%L<W0N96%4>7!E(#T](#!X1D9&1" I#0H@('L-"B @
  7900. XM("!F96%L<W0N<WI686QU95MF96%L<W0N96%3:7IE72 ](# [#0H@(" @<F5T
  7901. XM=7)N(&9E86QS="YS>E9A;'5E.PT*("!]#0H-"B @<F5T=7)N($Y53$P[#0I]
  7902. XM#0H-"@T*8VAA<B J1V5T3&]N9U!A=&A%02AC:&%R("IN86UE*0T*>PT*("!S
  7903. XM=&%T:6,@8VAA<B!N8G5F6T-#2$U!6%!!5$@@*R Q73L-"B @8VAA<B J8V]M
  7904. XM<"P@*FYE>'0L("IE82P@<V5P.PT*("!"3T],(&)&;W5N9" ]($9!3%-%.PT*
  7905. XM#0H@(&YB=69;,%T@/2 P.PT*("!N97AT(#T@;F%M93L-"@T*("!W:&EL92 H
  7906. XM("IN97AT("D-"B @>PT*(" @(&-O;7 @/2!N97AT.PT*#0H@(" @=VAI;&4@
  7907. XM*" J;F5X=" A/2 G7%PG("8F("IN97AT("$]("<O)R F)B J;F5X=" A/2 P
  7908. XM("D-"B @(" @(&YE>'0K*SL-"@T*(" @('-E<" ]("IN97AT.PT*(" @("IN
  7909. XM97AT(#T@,#L-"@T*(" @(&5A(#T@1V5T3&]N9TYA;65%02AN86UE*3L-"B @
  7910. XM("!S=')C870H;F)U9BP@96$@/R!E82 Z(&-O;7 I.PT*(" @(&)&;W5N9" ]
  7911. XM(&)&;W5N9"!\?" H96$@(3T@3E5,3"D[#0H-"B @(" J;F5X=" ]('-E<#L-
  7912. XM"@T*(" @(&EF("@@*FYE>'0@*0T*(" @('L-"B @(" @('-T<F-A="AN8G5F
  7913. XM+" B7%PB*3L-"B @(" @(&YE>'0K*SL-"B @("!]#0H@('T-"@T*("!R971U
  7914. XM<FX@;F)U9ELP72 F)B!B1F]U;F0@/R!N8G5F(#H@3E5,3#L-"GT-"@T*#0HO
  7915. XM*B!G96YE<F%L($5!(&-O9&4@*B\-"@T*='EP961E9B!S=')U8W0-"GL-"B @
  7916. XM55-(3U)4(&Y)1#L-"B @55-(3U)4(&Y3:7IE.PT*("!53$].1R!L4VEZ93L-
  7917. XM"GT-"D5!2$5!1$52+" J4$5!2$5!1$52.PT*#0H-"B-I9F1E9B!?7S,R0DE4
  7918. XM7U\-"@T*+RH@4&5R:&%P<R!D=64@=&\@8G5G<R!I;B!T:&4@8W5R<F5N="!/
  7919. XM4R\R(#(N,"!K97)N96PL('1H92!S=6-C97-S(&]R#0H@("!F86EL=7)E(&]F
  7920. XM('1H92!$;W-%;G5M071T<FEB=71E*"D@86YD($1O<U%U97)Y4&%T:$EN9F\H
  7921. XM*2!S>7-T96T@8V%L;',-"B @(&1E<&5N9',@;VX@=&AE(&%R96$@=VAE<F4@
  7922. XM=&AE(')E='5R;B!B=69F97)S(&%R92!A;&QO8V%T960N(%1H:7,-"B @(&1I
  7923. XM9F9E<G,@9F]R('1H92!V87)I;W5S(&-O;7!I;&5R<RP@9F]R('-O;64@86QL
  7924. XM;V-A*"D@=V]R:W,L(&9O<B!S;VUE#0H@("!M86QL;V,H*2!W;W)K<RP@9F]R
  7925. XM('-O;64L(&)O=&@@=V]R:RX@5V4G;&P@:&%V92!T;R!L:79E('=I=&@@=&AA
  7926. XM="X@*B\-"@T*+RH@5&AE('5S92!O9B!M86QL;V,H*2!I<R!N;W0@=F5R>2!C
  7927. XM;VYV96YI96YT+"!B96-A=7-E(&ET(')E<75I<F5S#0H@("!B86-K=')A8VMI
  7928. XM;F<@*&DN92X@9G)E92@I*2!A="!E<G)O<B!R971U<FYS+B!792!D;R!T:&%T
  7929. XM(&9O<B!S>7-T96T-"B @(&-A;&QS('1H870@;6%Y(&9A:6PL(&)U="!N;W0@
  7930. XM9F]R(&UA;&QO8R@I(&-A;&QS+"!B96-A=7-E('1H97D@87)E(%9%4ED-"B @
  7931. XM('5N;&EK96QY('1O(&9A:6PN($EF(&5V97(L('=E(&IU<W0@;&5A=F4@<V]M
  7932. XM92!M96UO<GD@86QL;V-A=&5D("XN+B J+PT*#0HC:68@9&5F:6YE9"A?7T=.
  7933. XM54-?7RD@?'P@9&5F:6YE9"A?7TE"34-?7RD-"B-D969I;F4@86QL;V,@86QL
  7934. XM;V-A#0HC96YD:68-"@T*(VEF9&5F(%]?5T%40T]-0U]?#0HC9&5F:6YE(&%L
  7935. XM;&]C(&UA;&QO8PT*(V1E9FEN92!?7T92145?7PT*(V5N9&EF#0H-"B-I9FYD
  7936. XM968@86QL;V,-"B-E<G)O<B!M96UO<GD@86QL;V-A=&EO;B!T>7!E("AA;&QO
  7937. XM8V$@;W(@;6%L;&]C*2!N;W0@<W!E8VEF:65D#0HC96YD:68-"@T*=F]I9"!'
  7938. XM971%07,H8VAA<B J<&%T:"P@8VAA<B J*F)U9G!T<BP@=6YS:6=N960@*G-I
  7939. XM>F4L#0H@(" @(" @(" @(" @(" @(" @(" @("!C:&%R("HJ8V)U9G!T<BP@
  7940. XM=6YS:6=N960@*F-S:7IE*0T*>PT*("!&24Q%4U1!5%53-"!F<SL-"B @4$1%
  7941. XM3D$R('!$14Y!+"!P1F]U;F0[#0H@($5!3U R(&5A;W [#0H@(%!'14$R('!'
  7942. XM14$[#0H@(%!'14$R3$E35"!P1T5!;&ES=#L-"B @4$9%03),25-4('!&14%L
  7943. XM:7-T.PT*("!014%(14%$15(@<$5!8FQO8VL[#0H@(%5,3TY'('5L071T<FEB
  7944. XM=71E<RP@=6Q-96UO<GE";&]C:SL-"B @54Q/3D<@;DQE;F=T:#L-"B @8VAA
  7945. XM<B!S>DYA;65;0T-(34%84$%42%T[#0H-"B @*G-I>F4@/2 J8W-I>F4@/2 P
  7946. XM.PT*#0H@(&EF("@@7V]S;6]D92 ]/2!$3U-?34]$12 I#0H@(" @<F5T=7)N
  7947. XM.PT*#0H@('-T<F-P>2AS>DYA;64L('!A=&@I.PT*("!N3&5N9W1H(#T@<W1R
  7948. XM;&5N*'-Z3F%M92D[#0H@(&EF("@@<WI.86UE6VY,96YG=&@@+2 Q72 ]/2 G
  7949. XM+R<@*0T*(" @('-Z3F%M95MN3&5N9W1H("T@,5T@/2 P.PT*#0H@(&EF("@@
  7950. XM1&]S475E<GE0871H26YF;RAS>DYA;64L($9)3%]15452645!4TE:12P@*%!"
  7951. XM651%*2 F9G,L('-I>F5O9BAF<RDI#0H@(" @?'P@9G,N8V),:7-T(#P](#(@
  7952. XM*B!S:7IE;V8H54Q/3D<I#0H@(" @?'P@*'!$14Y!(#T@86QL;V,H*'-I>F5?
  7953. XM="D@9G,N8V),:7-T*2D@/3T@3E5,3" I#0H@(" @<F5T=7)N.PT*#0H@('5L
  7954. XM071T<FEB=71E<R ]("TQ.PT*#0H@(&EF("@@1&]S16YU;4%T=')I8G5T92A%
  7955. XM3E5-14%?4D5&5%E015]0051(+"!S>DYA;64L(#$L('!$14Y!+"!F<RYC8DQI
  7956. XM<W0L#0H@(" @(" @(" @(" @(" @(" @(" @(" F=6Q!='1R:6)U=&5S+"!%
  7957. XM3E5-14%?3$5614Q?3D]?5D%,544I#0H@(" @?'P@=6Q!='1R:6)U=&5S(#T]
  7958. XM(# -"B @("!\?" H<$=%06QI<W0@/2!A;&QO8R@H<VEZ95]T*2!F<RYC8DQI
  7959. XM<W0I*2 ]/2!.54Q,("D-"B @>PT*(VEF9&5F(%]?1E)%15]?#0H@(" @9G)E
  7960. XM92AP1$5.02D[#0HC96YD:68-"B @("!R971U<FX[#0H@('T-"@T*("!P1T5!
  7961. XM(#T@<$=%06QI<W0@+3X@;&ES=#L-"B @<$9O=6YD(#T@<$1%3D$[#0H-"B @
  7962. XM=VAI;&4@*"!U;$%T=')I8G5T97,M+2 I#0H@('L-"B @("!I9B H("$H<W1R
  7963. XM8VUP*'!&;W5N9" M/B!S>DYA;64L("(N3$].1TY!344B*2 ]/2 P("8F('5S
  7964. XM95]L;VYG;F%M95]E82D@*0T*(" @('L-"B @(" @('!'14$@+3X@8V).86UE
  7965. XM(#T@<$9O=6YD("T^(&-B3F%M93L-"B @(" @('-T<F-P>2AP1T5!("T^('-Z
  7966. XM3F%M92P@<$9O=6YD("T^('-Z3F%M92D[#0H-"B @(" @(&Y,96YG=&@@/2!S
  7967. XM:7IE;V8H1T5!,BD@*R!S=')L96XH<$=%02 M/B!S>DYA;64I.PT*(" @(" @
  7968. XM;DQE;F=T:" ]("@H;DQE;F=T:" M(#$I("\@<VEZ96]F*%5,3TY'*2 K(#$I
  7969. XM("H@<VEZ96]F*%5,3TY'*3L-"@T*(" @(" @<$=%02 M/B!O3F5X=$5N=')Y
  7970. XM3V9F<V5T(#T@=6Q!='1R:6)U=&5S(#\@;DQE;F=T:" Z(# [#0H@(" @("!P
  7971. XM1T5!(" @/2 H4$=%03(I(" H*%!#2"D@<$=%02 K(&Y,96YG=&@I.PT*(" @
  7972. XM('T-"@T*(" @('!&;W5N9" ]("A01$5.03(I("@H4$-(*2!P1F]U;F0@*R!P
  7973. XM1F]U;F0@+3X@;TYE>'1%;G1R>4]F9G-E="D[#0H@('T-"@T*("!I9B H('!'
  7974. XM14$@/3T@<$=%06QI<W0@+3X@;&ES=" I("\J(&YO(&%T=')I8G5T97,@=&\@
  7975. XM<V%V92 J+PT*("![#0HC:69D968@7U]&4D5%7U\-"B @("!F<F5E*'!$14Y!
  7976. XM*3L-"B @("!F<F5E*'!'14%L:7-T*3L-"B-E;F1I9@T*(" @(')E='5R;CL-
  7977. XM"B @?0T*#0H@('!'14%L:7-T("T^(&-B3&ES=" ]("A00T@I('!'14$@+2 H
  7978. XM4$-(*2!P1T5!;&ES=#L-"@T*("!P1D5!;&ES=" ]("A05D])1"D@<$1%3D$[
  7979. XM(" O*B!R975S92!B=69F97(@*B\-"B @<$9%06QI<W0@+3X@8V),:7-T(#T@
  7980. XM9G,N8V),:7-T.PT*#0H@(&5A;W N9G!'14$R3&ES=" ]('!'14%L:7-T.PT*
  7981. XM("!E86]P+F9P1D5!,DQI<W0@/2!P1D5!;&ES=#L-"B @96%O<"YO17)R;W(@
  7982. XM/2 P.PT*#0H@(&EF("@@1&]S475E<GE0871H26YF;RAS>DYA;64L($9)3%]1
  7983. XM5452645!4T923TU,25-4+ T*(" @(" @(" @(" @(" @(" @(" @(" @*%!"
  7984. XM651%*2 F96%O<"P@<VEZ96]F*&5A;W I*2 I#0H@('L-"B-I9F1E9B!?7T92
  7985. XM145?7PT*(" @(&9R964H<$1%3D$I.PT*(" @(&9R964H<$=%06QI<W0I.PT*
  7986. XM(V5N9&EF#0H@(" @<F5T=7)N.PT*("!]#0H-"B @+RH@5&AE(&UA>&EM=6T@
  7987. XM8V]M<')E<W-E9"!S:7IE(&ES("AI;B!C87-E(&]F(%-43U)%('1Y<&4I('1H
  7988. XM90T*(" @("!U;F-O;7!R97-S960@<VEZ92!P;'5S('1H92!S:7IE(&]F('1H
  7989. XM92!C;VUP<F5S<VEO;B!T>7!E(&9I96QD#0H@(" @('!L=7,@=&AE('-I>F4@
  7990. XM;V8@=&AE($-20R!F:65L9"X@*B\-"@T*("!U;$%T=')I8G5T97,@/2!P1D5!
  7991. XM;&ES=" M/B!C8DQI<W0[#0H@('5L365M;W)Y0FQO8VL@/2!U;$%T=')I8G5T
  7992. XM97,@*R!S:7IE;V8H55-(3U)4*2 K('-I>F5O9BA53$].1RD[#0H@('!%06)L
  7993. XM;V-K(#T@*%!%04A%041%4BD@;6%L;&]C*'-I>F5O9BA%04A%041%4BD@*R!U
  7994. XM;$UE;6]R>4)L;V-K*3L-"@T*("!I9B H('!%06)L;V-K(#T]($Y53$P@*0T*
  7995. XM(" @(')E='5R;CL-"@T*(" J8G5F<'1R(#T@*&-H87(@*BD@<$5!8FQO8VL[
  7996. XM#0H@("IS:7IE(#T@<VEZ96]F*$5!2$5!1$52*3L-"@T*("!P14%B;&]C:R M
  7997. XM/B!N240@/2!%04E$.PT*("!P14%B;&]C:R M/B!N4VEZ92 ]('-I>F5O9BAP
  7998. XM14%B;&]C:R M/B!L4VEZ92D[#0H@('!%06)L;V-K("T^(&Q3:7IE(#T@=6Q!
  7999. XM='1R:6)U=&5S.R O*B!U;F-O;7!R97-S960@<VEZ92 J+PT*#0H@(&Y,96YG
  8000. XM=&@@/2!M96UC;VUP<F5S<R@H8VAA<B J*2 H<$5!8FQO8VL@*R Q*2P@=6Q-
  8001. XM96UO<GE";&]C:RP-"B @(" @(" @(" @(" @(" @(" @(" @("AC:&%R("HI
  8002. XM('!&14%L:7-T+"!U;$%T=')I8G5T97,I.PT*(" J<VEZ92 K/2!N3&5N9W1H
  8003. XM.PT*("!P14%B;&]C:R M/B!N4VEZ92 K/2!N3&5N9W1H.PT*#0H@(&EF("@@
  8004. XM*'!%06)L;V-K(#T@*%!%04A%041%4BD@;6%L;&]C*'-I>F5O9BA%04A%041%
  8005. XM4BDI*2 ]/2!.54Q,("D-"B @("!R971U<FX[#0H-"B @*F-B=69P='(@/2 H
  8006. XM8VAA<B J*2!P14%B;&]C:SL-"B @*F-S:7IE(#T@<VEZ96]F*$5!2$5!1$52
  8007. XM*3L-"@T*("!P14%B;&]C:R M/B!N240@/2!%04E$.PT*("!P14%B;&]C:R M
  8008. XM/B!N4VEZ92 ]('-I>F5O9BAP14%B;&]C:R M/B!L4VEZ92D[#0H@('!%06)L
  8009. XM;V-K("T^(&Q3:7IE(#T@=6Q!='1R:6)U=&5S.PT*#0H@(&EF("@@;F]I<WD@
  8010. XM*0T*(" @('!R:6YT9B@B("@E;&0@8GET97,@14$G<RDB+"!U;$%T=')I8G5T
  8011. XM97,I.PT*?0T*#0HC96QS92 O*B A7U\S,D))5%]?("HO#0H-"G1Y<&5D968@
  8012. XM<W1R=6-T#0I[#0H@(%5,3TY'(&].97AT16YT<GE/9F9S970[#0H@($)95$4@
  8013. XM9D5!.PT*("!"651%(&-B3F%M93L-"B @55-(3U)4(&-B5F%L=64[#0H@($-(
  8014. XM05(@<WI.86UE6S%=.PT*?0T*1D5!,BP@*E!&14$R.PT*#0IT>7!E9&5F('-T
  8015. XM<G5C= T*>PT*("!53$].1R!C8DQI<W0[#0H@($9%03(@;&ES=%LQ73L-"GT-
  8016. XM"D9%03),25-4+" J4$9%03),25-4.PT*#0IV;VED($=E=$5!<RAC:&%R("IP
  8017. XM871H+"!C:&%R("HJ8G5F<'1R+"!U;G-I9VYE9" J<VEZ92P-"B @(" @(" @
  8018. XM(" @(" @(" @(" @(" @(&-H87(@*BIC8G5F<'1R+"!U;G-I9VYE9" J8W-I
  8019. XM>F4I#0I[#0H@($9)3$535$%455,R(&9S.PT*("!01$5.03$@<$1%3D$L('!&
  8020. XM;W5N9#L-"B @14%/4"!E86]P.PT*("!01T5!3$E35"!P1T5!;&ES=#L-"B @
  8021. XM4$=%02!P1T5!.PT*("!01D5!3$E35"!P1D5!;&ES=#L-"B @4$9%02!P1D5!
  8022. XM.PT*("!01D5!,DQ)4U0@<$9%03)L:7-T.PT*("!01D5!,B!P1D5!,CL-"B @
  8023. XM14%(14%$15(@*G!%06)L;V-K.PT*("!53$].1R!U;$%T=')I8G5T97,[#0H@
  8024. XM(%532$]25"!N3&5N9W1H+"!N36%X4VEZ93L-"B @8VAA<B!S>DYA;65;0T-(
  8025. XM34%84$%42%T[#0H-"B @*G-I>F4@/2 J8W-I>F4@/2 P.PT*#0H@(&EF("@@
  8026. XM7V]S;6]D92 ]/2!$3U-?34]$12 I#0H@(" @<F5T=7)N.PT*#0H@('-T<F-P
  8027. XM>2AS>DYA;64L('!A=&@I.PT*("!N3&5N9W1H(#T@<W1R;&5N*'-Z3F%M92D[
  8028. XM#0H@(&EF("@@<WI.86UE6VY,96YG=&@@+2 Q72 ]/2 G+R<@*0T*(" @('-Z
  8029. XM3F%M95MN3&5N9W1H("T@,5T@/2 P.PT*#0H@(&EF("@@1&]S475E<GE0871H
  8030. XM26YF;RAS>DYA;64L($9)3%]15452645!4TE:12P@*%!"651%*2 F9G,L('-I
  8031. XM>F5O9BAF<RDI#0H@(" @?'P@9G,N8V),:7-T(#P](#(@*B!S:7IE;V8H54Q/
  8032. XM3D<I("D-"B @("!R971U<FX[#0H-"B @=6Q!='1R:6)U=&5S(#T@+3$[#0H@
  8033. XM(&Y-87A3:7IE(#T@*%532$]25"D@;6EN*&9S+F-B3&ES=" J(#(L(#8U-3(P
  8034. XM3"D[#0H-"B @:68@*" H<$1%3D$@/2!M86QL;V,H*'-I>F5?="D@;DUA>%-I
  8035. XM>F4I*2 ]/2!.54Q,("D-"B @("!R971U<FX[#0H-"B @:68@*"!$;W-%;G5M
  8036. XM071T<FEB=71E*$5.54U%05]2149465!%7U!!5$@L('-Z3F%M92P@,2P@<$1%
  8037. XM3D$L(&9S+F-B3&ES="P-"B @(" @(" @(" @(" @(" @(" @(" @("9U;$%T
  8038. XM=')I8G5T97,L($5.54U%05],159%3%].3U]604Q512D-"B @("!\?"!U;$%T
  8039. XM=')I8G5T97,@/3T@, T*(" @('Q\("AP1T5!;&ES=" ](&UA;&QO8RAN36%X
  8040. XM4VEZ92DI(#T]($Y53$P@*0T*("![#0H@(" @9G)E92AP1$5.02D[#0H@(" @
  8041. XM<F5T=7)N.PT*("!]#0H-"B @<$=%02 ]('!'14%L:7-T("T^(&QI<W0[#0H@
  8042. XM('!&;W5N9" ]('!$14Y!.PT*#0H@('=H:6QE("@@=6Q!='1R:6)U=&5S+2T@
  8043. XM*0T*("![#0H@(" @;DQE;F=T:" ]('-T<FQE;BAP1F]U;F0@+3X@<WI.86UE
  8044. XM*3L-"@T*(" @(&EF("@@(2AS=')C;7 H<$9O=6YD("T^('-Z3F%M92P@(BY,
  8045. XM3TY'3D%-12(I(#T](# @)B8@=7-E7VQO;F=N86UE7V5A*2 I#0H@(" @>PT*
  8046. XM(" @(" @<$=%02 M/B!C8DYA;64@/2!P1F]U;F0@+3X@8V).86UE.PT*(" @
  8047. XM(" @<W1R8W!Y*'!'14$@+3X@<WI.86UE+"!P1F]U;F0@+3X@<WI.86UE*3L-
  8048. XM"@T*(" @(" @<$=%02 ]("A01T5!*2 H*%!#2"D@*'!'14$K*RD@*R!N3&5N
  8049. XM9W1H*3L-"B @("!]#0H-"B @("!P1F]U;F0@/2 H4$1%3D$Q*2 H*%!#2"D@
  8050. XM*'!&;W5N9"LK*2 K(&Y,96YG=&@I.PT*("!]#0H-"B @:68@*"!P1T5!(#T]
  8051. XM('!'14%L:7-T("T^(&QI<W0@*0T*("![#0H@(" @9G)E92AP1$5.02D[#0H@
  8052. XM(" @9G)E92AP1T5!;&ES="D[#0H@(" @<F5T=7)N.PT*("!]#0H-"B @<$=%
  8053. XM06QI<W0@+3X@8V),:7-T(#T@*%!#2"D@<$=%02 M("A00T@I('!'14%L:7-T
  8054. XM.PT*#0H@('!&14%L:7-T(#T@*%!&14%,25-4*2!P1$5.03L@+RH@<F5U<V4@
  8055. XM8G5F9F5R("HO#0H@('!&14%L:7-T("T^(&-B3&ES=" ](&9S+F-B3&ES=#L-
  8056. XM"B @<$9%02 ]('!&14%L:7-T("T^(&QI<W0[#0H-"B @96%O<"YF<$=%04QI
  8057. XM<W0@/2!P1T5!;&ES=#L-"B @96%O<"YF<$9%04QI<W0@/2!P1D5!;&ES=#L-
  8058. XM"B @96%O<"YO17)R;W(@/2 P.PT*#0H@(&EF("@@1&]S475E<GE0871H26YF
  8059. XM;RAS>DYA;64L($9)3%]15452645!4T923TU,25-4+ T*(" @(" @(" @(" @
  8060. XM(" @(" @(" H4$)95$4I("9E86]P+"!S:7IE;V8H96%O<"DI("D-"B @>PT*
  8061. XM(" @(&9R964H<$1%3D$I.PT*(" @(&9R964H<$=%06QI<W0I.PT*(" @(')E
  8062. XM='5R;CL-"B @?0T*#0H@("\J(&YO=R!C;VYV97)T(&EN=&\@;F5W($]3+S(@
  8063. XM,BXP(#,R+6)I="!F;W)M870@*B\-"@T*("!P1D5!,FQI<W0@/2 H4$9%03),
  8064. XM25-4*2!P1T5!;&ES=#L@("\J(')E=7-E(&)U9F9E<B J+PT*("!P1D5!,B ]
  8065. XM('!&14$R;&ES=" M/B!L:7-T.PT*#0H@('=H:6QE("@@*%!#2"D@<$9%02 M
  8066. XM("A00T@I('!&14%L:7-T(#P@<$9%06QI<W0@+3X@8V),:7-T("D-"B @>PT*
  8067. XM(" @(&Y,96YG=&@@/2!S:7IE;V8H1D5!*2 K('!&14$@+3X@8V).86UE("L@
  8068. XM,2 K('!&14$@+3X@8V)686QU93L-"B @("!M96UC<'DH*%!#2"D@<$9%03(@
  8069. XM*R!S:7IE;V8H<$9%03(@+3X@;TYE>'1%;G1R>4]F9G-E="DL('!&14$L(&Y,
  8070. XM96YG=&@I.PT*(" @(&UE;7-E="@H4$-(*2!P1D5!,B K('-I>F5O9BAP1D5!
  8071. XM,B M/B!O3F5X=$5N=')Y3V9F<V5T*2 K(&Y,96YG=&@L(# L(#,I.PT*(" @
  8072. XM('!&14$@/2 H4$9%02D@*"A00T@I('!&14$@*R!N3&5N9W1H*3L-"@T*(" @
  8073. XM(&Y,96YG=&@@/2!S:7IE;V8H1D5!,BD@*R!P1D5!,B M/B!C8DYA;64@*R Q
  8074. XM("L@<$9%03(@+3X@8V)686QU93L-"B @("!N3&5N9W1H(#T@*"AN3&5N9W1H
  8075. XM("T@,2D@+R!S:7IE;V8H54Q/3D<I("L@,2D@*B!S:7IE;V8H54Q/3D<I.PT*
  8076. XM(" @("\J(')O=6YD960@=7 @=&\@-"UB>71E(&)O=6YD87)Y("HO#0H@(" @
  8077. XM<$9%03(@+3X@;TYE>'1%;G1R>4]F9G-E=" ]#0H@(" @(" H*%!#2"D@<$9%
  8078. XM02 M("A00T@I('!&14%L:7-T(#P@<$9%06QI<W0@+3X@8V),:7-T*2 _(&Y,
  8079. XM96YG=&@@.B P.PT*(" @('!&14$R(#T@*%!&14$R*2 H*%!#2"D@<$9%03(@
  8080. XM*R!N3&5N9W1H*3L-"B @?0T*#0H@('!&14$R;&ES=" M/B!C8DQI<W0@/2 H
  8081. XM4$-(*2!P1D5!,B M("A00T@I('!&14$R;&ES=#L-"B @=6Q!='1R:6)U=&5S
  8082. XM(#T@<$9%03)L:7-T("T^(&-B3&ES=#L-"@T*("!P14%B;&]C:R ]("A014%(
  8083. XM14%$15(I('!$14Y!.R O*B!R975S92!B=69F97(@*B\-"@T*(" J8G5F<'1R
  8084. XM(#T@*&-H87(@*BD@<$5!8FQO8VL[#0H@("IS:7IE(#T@<VEZ96]F*$5!2$5!
  8085. XM1$52*3L-"@T*("!P14%B;&]C:R M/B!N240@/2!%04E$.PT*("!P14%B;&]C
  8086. XM:R M/B!N4VEZ92 ]('-I>F5O9BAP14%B;&]C:R M/B!L4VEZ92D[#0H@('!%
  8087. XM06)L;V-K("T^(&Q3:7IE(#T@=6Q!='1R:6)U=&5S.R O*B!U;F-O;7!R97-S
  8088. XM960@<VEZ92 J+PT*#0H@(&Y,96YG=&@@/2 H55-(3U)4*2!M96UC;VUP<F5S
  8089. XM<R@H8VAA<B J*2 H<$5!8FQO8VL@*R Q*2P-"B @("!N36%X4VEZ92 M('-I
  8090. XM>F5O9BA%04A%041%4BDL("AC:&%R("HI('!&14$R;&ES="P@=6Q!='1R:6)U
  8091. XM=&5S*3L-"@T*(" J<VEZ92 K/2!N3&5N9W1H.PT*("!P14%B;&]C:R M/B!N
  8092. XM4VEZ92 K/2!N3&5N9W1H.PT*#0H@('!%06)L;V-K(#T@*%!%04A%041%4BD@
  8093. XM<$=%06QI<W0[#0H-"B @*F-B=69P='(@/2 H8VAA<B J*2!P14%B;&]C:SL-
  8094. XM"B @*F-S:7IE(#T@<VEZ96]F*$5!2$5!1$52*3L-"@T*("!P14%B;&]C:R M
  8095. XM/B!N240@/2!%04E$.PT*("!P14%B;&]C:R M/B!N4VEZ92 ]('-I>F5O9BAP
  8096. XM14%B;&]C:R M/B!L4VEZ92D[#0H@('!%06)L;V-K("T^(&Q3:7IE(#T@=6Q!
  8097. XM='1R:6)U=&5S.PT*#0H@(&EF("@@;F]I<WD@*0T*(" @('!R:6YT9B@B("@E
  8098. XM;&0@8GET97,@14$G<RDB+"!U;$%T=')I8G5T97,I.PT*?0T*#0HC96YD:68@
  8099. XM+RH@7U\S,D))5%]?("HO#0H-"@T*(V5N9&EF("\J(%5424P@*B\-"@T*#0HO
  8100. XM*B!);FET:6%L:7IE('1H92!T86)L92!O9B!U<'!E<F-A<V4@8VAA<F%C=&5R
  8101. XM<R!I;F-L=61I;F<@:&%N9&QI;F<@;V8-"B @(&-O=6YT<GD@9&5P96YD96YT
  8102. XM(&-H87)A8W1E<G,N("HO#0H-"G9O:60@:6YI=%]U<'!E<B@I#0I[#0H@($-/
  8103. XM54Y44EE#3T1%(&-C.PT*("!U;G-I9VYE9"!N0VYT+"!N53L-"@T*("!F;W(@
  8104. XM*"!N0VYT(#T@,#L@;D-N=" \('-I>F5O9BAU<'!E<BD[(&Y#;G0K*R I#0H@
  8105. XM(" @=7!P97);;D-N=%T@/2!L;W=E<EMN0VYT72 ]("AU;G-I9VYE9"!C:&%R
  8106. XM*2!N0VYT.PT*#0H@(&-C+F-O=6YT<GD@/2!C8RYC;V1E<&%G92 ](# [#0H@
  8107. XM($1O<TUA<$-A<V4H<VEZ96]F*'5P<&5R*2P@)F-C+" H4$-(05(I('5P<&5R
  8108. XM*3L-"@T*("!F;W(@*"!N0VYT(#T@,#L@;D-N=" \(#(U-CL@;D-N="LK("D-
  8109. XM"B @>PT*(" @(&Y5(#T@=7!P97);;D-N=%T[#0H@(" @:68@*&Y5("$](&Y#
  8110. XM;G0@)B8@;&]W97);;E5=(#T]("AU;G-I9VYE9"!C:&%R*2!N52D-"B @(" @
  8111. XM(&QO=V5R6VY572 ]("AU;G-I9VYE9"!C:&%R*2!N0VYT.PT*("!]#0H-"B @
  8112. XM9F]R("@@;D-N=" ]("=!)SL@;D-N=" \/2 G6B<[(&Y#;G0K*R I#0H@(" @
  8113. XM;&]W97);;D-N=%T@/2 H=6YS:6=N960@8VAA<BD@*&Y#;G0@+2 G02<@*R G
  8114. XM82<I.PT*?0T*#0H-"F-H87(@*E-T<FEN9TQO=V5R*&-H87(@*G-Z07)G*0T*
  8115. XM>PT*("!U;G-I9VYE9"!C:&%R("IS>E!T<CL-"B @9F]R("@@<WI0='(@/2!S
  8116. XM>D%R9SL@*G-Z4'1R.R!S>E!T<BLK("D-"B @(" J<WI0='(@/2!L;W=E<ELJ
  8117. X=<WI0=')=.PT*("!R971U<FX@<WI!<F<[#0I]#0HJ
  8118. Xend
  8119. END_OF_FILE
  8120.  if test 28901 -ne `wc -c <'os2/os2zip.c.UU'`; then
  8121.     echo shar: \"'os2/os2zip.c.UU'\" unpacked with wrong size!
  8122.   else
  8123.     echo shar: Uudecoding \"'os2/os2zip.c'\" \(20954 characters\)
  8124.     cat os2/os2zip.c.UU | uudecode
  8125.     if test 20954 -ne `wc -c <'os2/os2zip.c'`; then
  8126.       echo shar: \"'os2/os2zip.c'\" uudecoded with wrong size!
  8127.     else
  8128.       rm os2/os2zip.c.UU
  8129.     fi
  8130.   fi
  8131.   # end of 'os2/os2zip.c.UU'
  8132. fi
  8133. echo shar: End of archive 5 \(of 11\).
  8134. cp /dev/null ark5isdone
  8135. MISSING=""
  8136. for I in 1 2 3 4 5 6 7 8 9 10 11 ; do
  8137.     if test ! -f ark${I}isdone ; then
  8138.     MISSING="${MISSING} ${I}"
  8139.     fi
  8140. done
  8141. if test "${MISSING}" = "" ; then
  8142.     echo You have unpacked all 11 archives.
  8143.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  8144. else
  8145.     echo You still must unpack the following archives:
  8146.     echo "        " ${MISSING}
  8147. fi
  8148. exit 0
  8149. exit 0 # Just in case...
  8150. Newsgroups: comp.sources.misc
  8151. From: zip-bugs@cs.ucla.edu (Info-ZIP group)
  8152. Subject:  v31i098:  zip19 - Info-ZIP portable Zip, version 1.9, Part06/11
  8153. Message-ID: <1992Aug23.064718.29270@sparky.imd.sterling.com>
  8154. X-Md4-Signature: cc24ed17dbea073912fe1473810d2c72
  8155. Date: Sun, 23 Aug 1992 06:47:18 GMT
  8156. Approved: kent@sparky.imd.sterling.com
  8157.  
  8158. Submitted-by: zip-bugs@cs.ucla.edu (Info-ZIP group)
  8159. Posting-number: Volume 31, Issue 98
  8160. Archive-name: zip19/part06
  8161. Supersedes: zip: Volume 23, Issue 88-96
  8162. Environment: UNIX, VMS, OS/2, MS-DOS, MACINTOSH, WIN-NT, LINUX, MINIX, XOS, !AMIGA, ATARI, symlink, SGI, DEC, Cray, Convex, Amdahl, Sun, PC
  8163.  
  8164. #! /bin/sh
  8165. # This is a shell archive.  Remove anything before this line, then feed it
  8166. # into a shell via "sh file" or similar.  To overwrite existing files,
  8167. # type "sh file -c".
  8168. # The tool that generated this appeared in the comp.sources.unix newsgroup;
  8169. # send mail to comp-sources-unix@uunet.uu.net if you want that tool.
  8170. # Contents:  os2/zip.def.UU zip.1 zip.h zipfile.c
  8171. # Wrapped by kent@sparky on Sun Aug 23 01:00:45 1992
  8172. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  8173. echo If this archive is complete, you will see the following message:
  8174. echo '          "shar: End of archive 6 (of 11)."'
  8175. if test -f 'os2/zip.def.UU' -a "${1}" != "-c" ; then 
  8176.   echo shar: Will not clobber existing file \"'os2/zip.def.UU'\"
  8177. else
  8178.   echo shar: Extracting \"'os2/zip.def.UU'\" \(152 characters\)
  8179.   sed "s/^X//" >'os2/zip.def.UU' <<'END_OF_FILE'
  8180. Xbegin 666 os2/zip.def
  8181. XM3D%-12!724Y$3U=#3TU0050@3D571DE,15,-"D1%4T-225!424].("=4:&4@
  8182. XK=V]R;&0M9F%M;W5S('II<"!U=&EL:71I97,@9G)O;2!);F9O+5I)4"<-"F4@
  8183. Xend
  8184. END_OF_FILE
  8185.  if test 152 -ne `wc -c <'os2/zip.def.UU'`; then
  8186.     echo shar: \"'os2/zip.def.UU'\" unpacked with wrong size!
  8187.   else
  8188.     echo shar: Uudecoding \"'os2/zip.def'\" \(88 characters\)
  8189.     cat os2/zip.def.UU | uudecode
  8190.     if test 88 -ne `wc -c <'os2/zip.def'`; then
  8191.       echo shar: \"'os2/zip.def'\" uudecoded with wrong size!
  8192.     else
  8193.       rm os2/zip.def.UU
  8194.     fi
  8195.   fi
  8196.   # end of 'os2/zip.def.UU'
  8197. fi
  8198. if test -f 'zip.1' -a "${1}" != "-c" ; then 
  8199.   echo shar: Will not clobber existing file \"'zip.1'\"
  8200. else
  8201.   echo shar: Extracting \"'zip.1'\" \(21796 characters\)
  8202.   sed "s/^X//" >'zip.1' <<'END_OF_FILE'
  8203. X.\" Copyright (C) 1990-1992 Mark Adler, Richard B. Wales, Jean-loup Gailly,
  8204. X.\" Kai Uwe Rommel and Igor Mandrichenko.
  8205. X.\" Permission is granted to any individual or institution to use, copy, or
  8206. X.\" redistribute this software so long as all of the original files are included
  8207. X.\" unmodified, that it is not sold for profit, and that this copyright notice
  8208. X.\" is retained.
  8209. X.\"
  8210. X.\" zip.1 by Mark Adler.
  8211. X.\"
  8212. X.TH ZIP 1
  8213. X.SH NAME
  8214. Xzip, zipcloak, zipnote, zipsplit \- package and compress (archive) files
  8215. X.SH SYNOPSIS
  8216. X.B zip
  8217. X[
  8218. X.B \-cdeEfghjklmoqruwyz@
  8219. X] [
  8220. X.B \-b
  8221. Xtemppath ] [
  8222. X.B \-n
  8223. Xsuffixes ] [
  8224. X.B \-t
  8225. Xmmddyy ] [ zipfile list ] [
  8226. X.B \-x
  8227. Xlist ]
  8228. X.PP
  8229. X.B zipcloak
  8230. X[
  8231. X.B \-d
  8232. X] [
  8233. X.BI -b " path"
  8234. X]
  8235. X.I zipfile
  8236. X.PP
  8237. X.B zipnote
  8238. X[
  8239. X.B -w
  8240. X] [
  8241. X.BI \-b " path"
  8242. X]
  8243. X.I zipfile
  8244. X.PP
  8245. X.B zipsplit
  8246. X[
  8247. X.B \-ti
  8248. X] [
  8249. X.BI \-n " size"
  8250. X] [
  8251. X.BI \-b " path"
  8252. X]
  8253. X.I zipfile
  8254. X.br
  8255. X.SH DESCRIPTION
  8256. X.I zip
  8257. Xis a compression and file packaging utility for Unix, VMS, MSDOS,
  8258. XOS/2, Windows NT, Minix, Atari and Macintosh.  It is analogous to a
  8259. Xcombination of tar and compress and is compatible with PKZIP (Phil
  8260. XKatz ZIP) for MSDOS systems.
  8261. X.PP
  8262. XThere is a companion to
  8263. X.I zip
  8264. Xcalled
  8265. X.I unzip
  8266. X(of course) which you should be able
  8267. Xto find the same place you got
  8268. X.I zip.  zip
  8269. Xand
  8270. X.I unzip
  8271. Xcan work with files
  8272. Xproduced by PKZIP under MSDOS, and PKZIP and PKUNZIP can work with files
  8273. Xproduced by
  8274. X.I zip.
  8275. X.PP
  8276. X.I zip
  8277. Xversion 1.9 is compatible with pkzip 1.93a.
  8278. XNote that pkunzip 1.10 cannot extract files produced by pkzip 1.93a
  8279. Xor zip 1.9. You must use pkunzip 1.93a or unzip 5.0 to extract them.
  8280. X.PP
  8281. XFor a brief help on
  8282. X.I zip
  8283. Xand
  8284. X.I unzip,
  8285. Xrun each without specifying any parameters on the command line.
  8286. X.PP
  8287. X.I zip
  8288. Xputs one or more compressed files into a single "zip file" along with
  8289. Xinformation about the files, including the name, path if requested, date
  8290. Xand time last modified, protection, and check information to verify the
  8291. Xfidelity of each entry.
  8292. X.I zip
  8293. Xcan also be used as a filter, compressing standard input to standard output.
  8294. X.I zip
  8295. Xcan pack an entire directory structure in a
  8296. Xzip file with a single command.  Compression ratios of 2:1 to 3:1 are
  8297. Xcommon for text files.
  8298. X.I zip
  8299. Xhas one compression method (deflation) and can also store files without
  8300. Xcompression. It automatically chooses the better of the two for each file
  8301. Xto be compressed.
  8302. X.PP
  8303. X.I zip
  8304. Xis useful for packaging a set of files to send to someone or for distribution;
  8305. Xfor archiving or backing up files; and for saving disk space by temporarily
  8306. Xcompressing unused files or directories.
  8307. X.SH "HOW TO USE ZIP"
  8308. XThe simplest use of
  8309. X.I zip
  8310. Xis as follows:
  8311. X.PP
  8312. X.ti +5n
  8313. Xzip stuff *
  8314. X.PP
  8315. XThis will create the file "stuff.zip" (assuming it does not exist) and put
  8316. Xall the files in the current directory in stuff.zip in a compressed form.
  8317. XThe .zip suffix is added automatically, unless that file name given contains
  8318. Xa dot already.  This allows specifying suffixes other than ".zip".
  8319. X.PP
  8320. XBecause of the way the shell does filename substitution, files that start
  8321. Xwith a "." are not included.  To include those as well, you can:
  8322. X.PP
  8323. X.ti +5n
  8324. Xzip stuff .* *
  8325. X.PP
  8326. XEven this will not include any subdirectories that are in the current
  8327. Xdirectory.  To zip up an entire directory, the command:
  8328. X.PP
  8329. X.ti +5n
  8330. Xzip -r foo foo
  8331. X.PP
  8332. Xwill create the file "foo.zip" containing all the files and directories in
  8333. Xthe directory "foo" that is in the current directory. (The first "foo" denotes
  8334. Xthe zip file, the second one denotes the directory.)  The "r" option means
  8335. Xrecurse through the directory structure.  In this case, all the
  8336. Xfiles and directories in foo are zipped, including the ones that start with
  8337. Xa ".", since the recursion does not use the shell's file-name substitution.
  8338. XYou should not use -r with the name ".*", since that matches ".." which will
  8339. Xattempt to zip up the parent directory--probably not what was intended.
  8340. X.PP
  8341. XYou may want to make a zip file that contains the files in foo, but not record
  8342. Xthe directory name, foo.  You can use the -j (junk path) option to leave off
  8343. Xthe path:
  8344. X.PP
  8345. X.ti +5n
  8346. Xzip -j foo foo/*
  8347. X.PP
  8348. XThe -y option (only under Unix) will store symbolic links as such in the
  8349. Xzip file, instead of compressing and storing the file referred to in the link.
  8350. X.PP
  8351. XYou might be zipping to save disk space, in which case you could:
  8352. X.PP
  8353. X.ti +5n
  8354. Xzip -rm foo foo
  8355. X.PP
  8356. Xwhere the "m" option means "move".  This will delete foo and its contents
  8357. Xafter making foo.zip.  No deletions will be done until the zip has completed
  8358. Xwith no errors.  This option is obviously more dangerous and should be
  8359. Xused with care.
  8360. X.PP
  8361. XIf the zip file already exists, these commands will replace existing or add
  8362. Xnew entries to the zip file.  For example, if you were really short on disk
  8363. Xspace, you might not have enough room simultaneously to hold the directory
  8364. Xfoo and the compressed foo.zip.  In this case, you could do it in steps.  If
  8365. Xfoo contained the subdirectories tom, dick, and harry, then you could:
  8366. X.PP
  8367. X.ti +5n
  8368. Xzip -rm foo foo/tom
  8369. X.ti +5n
  8370. Xzip -rm foo foo/dick
  8371. X.ti +5n
  8372. Xzip -rm foo foo/harry
  8373. X.PP
  8374. Xwhere the first command would create foo.zip, and the next two would add to
  8375. Xit.  At the completion of each zip command, the directory just zipped would
  8376. Xbe deleted, making room in which the next
  8377. X.I zip
  8378. Xcommand could work.
  8379. X.PP
  8380. X.I zip
  8381. Xwill also accept a single dash ("-") as the zip file name, in which case it
  8382. Xwill write the zip file to stdout, allowing the output to be piped to another
  8383. Xprogram. For example:
  8384. X.PP
  8385. X.ti +5n
  8386. Xzip -r - . | dd of=/dev/nrst0 obs=16k
  8387. X.PP
  8388. Xwould write the zip output directly to a tape with the specified block size
  8389. Xfor the purpose of backing up the current directory.
  8390. X.PP
  8391. X.I zip
  8392. Xalso accepts a single dash ("-") as the name of a file to be compressed, in
  8393. Xwhich case it will read the zip file from stdin, allowing zip to take
  8394. Xinput from another program. For example:
  8395. X.PP
  8396. X.ti +5n
  8397. Xtar cf - . | zip backup -
  8398. X.PP
  8399. Xwould compress the output of the tar command for the purpose of backing up
  8400. Xthe current directory. This generally produces better compression than
  8401. Xthe previous example using the -r option, because
  8402. X.I zip
  8403. Xcan take advantage of redundancy between files. The backup can be restored
  8404. Xusing the command
  8405. X.PP
  8406. X.ti +5n
  8407. Xunzip -p backup | tar xf -
  8408. X.PP
  8409. XWhen no zip file name is given and stdout is not a terminal,
  8410. X.I zip
  8411. Xacts as a filter, compressing standard input to standard output.
  8412. XFor example,
  8413. X.PP
  8414. X.ti +5n
  8415. Xtar cf - . | zip | dd of=/dev/nrst0
  8416. X.PP
  8417. Xis equivalent to
  8418. X.PP
  8419. X.ti +5n
  8420. Xtar cf - . | zip - - | dd of=/dev/nrst0
  8421. X.PP
  8422. XZip archives created in this manner can be extracted with the program
  8423. X.I funzip
  8424. Xwhich is provided in the
  8425. X.I unzip
  8426. Xpackage. For example,
  8427. X.PP
  8428. X.ti +5n
  8429. X   dd if=/dev/nrst0 | funzip | tar xvf -
  8430. X.SH "MODIFYING EXISTING ZIP FILES"
  8431. XWhen given the name of an existing zip file with the above commands,
  8432. X.I zip
  8433. Xwill replace identically named entries in the
  8434. X.I zip
  8435. Xfile or add entries for
  8436. Xnew names.  For example, if foo.zip exists and contains foo/file1 and
  8437. Xfoo/file2, and the directory foo contains the files foo/file1 and foo/file3,
  8438. Xthen:
  8439. X.PP
  8440. X.ti +5n
  8441. Xzip -r foo foo
  8442. X.PP
  8443. Xwill replace foo/file1 in foo.zip and add foo/file3 to foo.zip.  After
  8444. Xthis, foo.zip contains foo/file1, foo/file2, and foo/file3, with foo/file2
  8445. Xunchanged from before.
  8446. X.PP
  8447. XWhen changing an existing zip file,
  8448. X.I zip
  8449. Xwill write a temporary file with
  8450. Xthe new contents, and only replace the old one when the zip has completed
  8451. Xwith no errors. You can use
  8452. Xthe -b option to specify a different path (usually a different device) to
  8453. Xput the temporary file in.  For example:
  8454. X.PP
  8455. X.ti +5n
  8456. Xzip -b /tmp stuff *
  8457. X.PP
  8458. Xwill put the temporary zip file and the temporary compression files in the
  8459. Xdirectory "/tmp", copying over stuff.zip in the current directory when
  8460. Xdone.
  8461. X.PP
  8462. XIf you are only adding entries to a zip file, not replacing, and the
  8463. X-g option is given, then
  8464. X.I zip
  8465. Xgrows (appends to) the file instead of copying it.  The danger of this is that
  8466. Xif the operation fails, the original zip file is corrupted and lost.
  8467. X.PP
  8468. XThere are two other ways to change or add entries in a zip file that are
  8469. Xrestrictions of simple addition or replacement.  The first is -u (update)
  8470. Xwhich will add new entries to the zip file as before but will replace
  8471. Xexisting entries only if the modified date of the file is more recent than
  8472. Xthe date recorded for that name in the zip file.  For example:
  8473. X.PP
  8474. X.ti +5n
  8475. Xzip -u stuff *
  8476. X.PP
  8477. Xwill add any new files in the current directory, and update any changed files
  8478. Xin the zip file stuff.zip.  Note that
  8479. X.I zip
  8480. Xwill not try to pack stuff.zip into
  8481. Xitself when you do this. 
  8482. X.I zip
  8483. Xwill always exclude the zip file from the files on which to be operated.
  8484. X.PP
  8485. XThe second restriction is -f (freshen) which, like update, will only replace
  8486. Xentries with newer files; unlike update, will not add files that are not
  8487. Xalready in the zip file.  For this option, you may want to simply freshen all
  8488. Xof the files that are in the specified zip file.  To do this you would simply:
  8489. X.PP
  8490. X.ti +5n
  8491. Xzip -f foo
  8492. X.PP
  8493. XNote that the -f option with no arguments freshens all the entries in the
  8494. Xzip file.  The same is true of -u, and hence "zip -u foo" and "zip -f foo"
  8495. Xboth do the same thing.
  8496. X.PP
  8497. XThis command should
  8498. Xbe run from the same directory from which the original zip command was run,
  8499. Xsince paths stored in zip files are always relative.
  8500. X.PP
  8501. XAnother restriction that can be used with adding, updating, or freshening is
  8502. X-t (time), which will not operate on files modified earlier than the specified
  8503. Xdate.  For example:
  8504. X.PP
  8505. X.ti +5n
  8506. Xzip -rt 120791 infamy foo
  8507. X.PP
  8508. Xwill add all the files in foo and its subdirectories that were last modified
  8509. Xon December 7, 1991, or later to the zip file infamy.zip.
  8510. X.PP
  8511. XAlso, files can be explicitly excluded using the -x option:
  8512. X.PP
  8513. X.ti +5n
  8514. Xzip -r foo foo -x \\*.o
  8515. X.PP
  8516. Xwhich will zip up the contents of foo into foo.zip but exclude all the
  8517. Xfiles that end in ".o".  Here the backslash causes
  8518. X.I zip
  8519. Xto match file names
  8520. Xthat were found when foo was searched.
  8521. X.PP
  8522. XThe last operation is -d (delete) which will remove entries from a zip file.
  8523. XAn example might be:
  8524. X.PP
  8525. X.ti +5n
  8526. Xzip -d foo foo/tom/junk foo/harry/\\* \\*.o
  8527. X.PP
  8528. Xwhich will remove the entry foo/tom/junk, all of the files that start with
  8529. X"foo/harry/", and all of the files that end with ".o" (in any path).  Note
  8530. Xthat once again, the shell expansion has been inhibited with backslashes, so
  8531. Xthat
  8532. X.I zip
  8533. Xcan see the asterisks.  
  8534. X.I zip
  8535. Xcan then match on the contents of the zip
  8536. Xfile instead of the contents of the current directory.
  8537. X.PP
  8538. XUnder MSDOS, -d is case sensitive when it matches names in the zip file.
  8539. XThis allows deleting names that were zipped on other systems, but requires
  8540. Xthat the names be entered in upper case if they were zipped on an MSDOS
  8541. Xsystem, so that the names can be found in the zip file and deleted.
  8542. X.SH "MORE OPTIONS"
  8543. XAs mentioned before,
  8544. X.I zip
  8545. Xwill use the best of two methods: deflate or store.
  8546. X.PP
  8547. XThe option -0 will force
  8548. X.I zip
  8549. Xto use store on all files. For example:
  8550. X.PP
  8551. X.ti +5n
  8552. Xzip -r0 foo foo
  8553. X.PP
  8554. Xwill zip up the directory foo into foo.zip using only store.
  8555. X.PP
  8556. XThe speed of deflation can also be controlled with options -1 (fastest
  8557. Xmethod but less compression) to -9 (best compression but slower). The
  8558. Xdefault value is -5. For example:
  8559. X.PP
  8560. X.ti +5n
  8561. Xzip -r8 foo foo
  8562. X.PP
  8563. XIn nearly all cases, a file that is already compressed cannot be compressed
  8564. Xfurther by
  8565. X.I zip,
  8566. Xor if it can, the effect is minimal.  The -n option prevents
  8567. X.I zip
  8568. Xfrom trying to compress files that have the given suffixes.
  8569. XSuch files are simply stored (0% compression) in the output zip file,
  8570. Xso that
  8571. X.I zip
  8572. Xdoesn't waste its time trying to compress them.
  8573. XThe suffixes are separated by
  8574. Xeither colons or semicolons.  For example:
  8575. X.PP
  8576. X.ti +5n
  8577. Xzip -rn ".Z:.zip:.tiff:.gif:.snd"  foo foo
  8578. X.PP
  8579. Xwill put everything in foo into foo.zip, but will store any files that end
  8580. Xin .Z, .zip, .tiff, .gif, or .snd without trying to compress them.  (Image
  8581. Xand sound files often have their own specialized compression methods.)
  8582. XThe default suffix list is ".Z:.zip;.zoo:.arc:.lzh:.arj".
  8583. XThe environment variable ZIPOPT can be used to change this default. For
  8584. Xexample under Unix with csh:
  8585. X.PP
  8586. X.ti +5n
  8587. Xsetenv ZIPOPT "-n .gif:.zip"
  8588. X.PP
  8589. XThe variable ZIPOPT can be used for any option and can include several
  8590. Xoptions.
  8591. X.PP
  8592. XUnder Unix and under OS/2 (if files from an HPFS are stored),
  8593. X.I zip
  8594. Xwill store the full path (relative to the current path) and name of the
  8595. Xfile (or just the name if -j is specified) in the zip file along with the
  8596. XUnix attributes, and it will mark
  8597. Xthe entry as made under Unix.  If the zip file is intended for PKUNZIP under
  8598. XMSDOS, then the -k (Katz) option should be used to attempt to convert the
  8599. Xnames and paths to conform to MSDOS, store only the MSDOS attribute (just
  8600. Xthe user write attribute from Unix), and mark the entry as made under MSDOS
  8601. X(even though it wasn't).
  8602. X.PP
  8603. XThe -o (older) option will set the "last modified" time of the zip file to
  8604. Xthe latest "last modified" time of the entries in the zip file.  This can
  8605. Xbe used without any other operations, if desired.  For example:
  8606. X.PP
  8607. X.ti +5n
  8608. Xzip -o foo
  8609. X.PP
  8610. Xwill change the last modified time of foo.zip to the latest time of the
  8611. Xentries in foo.zip.
  8612. X.PP
  8613. XThe -e and -c options operate on all files updated or added to the zip file.
  8614. XEncryption (-e) will prompt for a password on the terminal and will
  8615. Xnot echo the password as it is typed (if stderr is not a TTY, zip will exit
  8616. Xwith an error).  New zip entries will be encrypted using that password.  For
  8617. Xadded peace of mind, you can use -ee, which will prompt for the password
  8618. Xtwice, checking that the two are the same before using it. The encryption
  8619. Xcode is distributed separately, so the -e option may not be available
  8620. Xin your version.
  8621. X.PP
  8622. XOne-line comments can be added for each file with the -c option.  The zip
  8623. Xfile operations (adding or updating) will be done first, and you will then be
  8624. Xprompted for a one-line comment for each file.  You can then enter the comment
  8625. Xfollowed by return, or just return for no comment.
  8626. X.PP
  8627. XThe -z option will prompt you for a multi-line comment for the entire zip
  8628. Xfile.  This option can be used by itself, or in combination with other
  8629. Xoptions.  The comment is ended by a line containing just a period, or an end
  8630. Xof file condition (^D on Unix, ^Z on MSDOS, OS/2, and VAX/VMS).
  8631. XSince -z reads the
  8632. Xlines from stdin, you can simply take the comment from a file:
  8633. X.PP
  8634. X.ti +5n
  8635. Xzip -z foo < foowhat
  8636. X.PP
  8637. XThe -q (quiet) option eliminates the informational messages and comment prompts
  8638. Xwhile
  8639. X.I zip
  8640. Xis operating.  This might be used in shell scripts, for example, or if the
  8641. Xzip operation is being performed as a background task ("zip -q foo *.c &").
  8642. X.PP
  8643. X.I zip
  8644. Xcan take a list of file names to operate on from stdin using the -@ option.
  8645. XIn Unix, this option can be used with the find command to extend greatly
  8646. Xthe functionality of
  8647. X.I zip.
  8648. XFor example, to zip up all the C source files in the current directory and
  8649. Xits subdirectories, you can:
  8650. X.PP
  8651. X.ti +5n
  8652. Xfind . -type f -name "*.[ch]" -print | zip source -@
  8653. X.PP
  8654. XNote that the pattern must be quoted to keep the shell from expanding it.
  8655. X.PP
  8656. XUnder VMS only, the -w option will append the version number of the files to
  8657. Xthe name and zip up multiple versions of files.  Without -w,
  8658. X.I zip
  8659. Xwill only use the most recent version of the specified file(s).
  8660. X.PP
  8661. XThe -l option translates the Unix end-of-line character LF into the
  8662. XMSDOS convention CR LF. This option should not be used on binary files.
  8663. XThis option can be used on Unix if the zip file is intended for PKUNZIP
  8664. Xunder MSDOS. If the input files already contain CR LF, this option adds
  8665. Xan extra CR. This ensure that "unzip -a" on Unix will get back an exact
  8666. Xcopy of the original file, to undo the effect of "zip -l".
  8667. X.PP
  8668. XIf
  8669. X.I zip
  8670. Xis run with the -h option, or with no arguments and standard output is
  8671. Xa terminal, the license and the command-argument and option help is shown.
  8672. XThe -L option just shows the license.
  8673. X.SH "ABOUT PATTERN MATCHING"
  8674. X(Note: this section applies to Unix.  Watch this space for details on MSDOS
  8675. Xand VMS operation.)
  8676. X.PP
  8677. XThe Unix shell (sh or csh) does filename substitution on command arguments.
  8678. XThe special characters are ?, which matches any single character; * which
  8679. Xmatches any number of characters (including none); and [] which matches any
  8680. Xcharacter in the range inside the brackets (like [a\-f] or [0\-9]).  When
  8681. Xthese characters are encountered (and not escaped with a backslash or
  8682. Xquotes), the
  8683. Xshell will look for files relative to the current path that match the
  8684. Xpattern, and replace the argument with a list of the names that matched.
  8685. X.PP
  8686. X.I zip
  8687. Xcan do the same matching on names that are in the zip file being
  8688. Xmodified or, in the case of the -x (exclude) option, on the list of
  8689. Xfiles to be operated on, by using backslashes or quotes
  8690. Xto tell the shell not to do the name expansion.  In general, when
  8691. X.I zip
  8692. Xencounters a name in the list
  8693. Xof files to do, it first looks for the name in the file system.  If it
  8694. Xfinds it, it then adds it to the list of files to do.  If it does not
  8695. Xfind it, it will look for the name in the zip file being modified (if it
  8696. Xexists), using the pattern matching characters above, if any.  For each
  8697. Xmatch, it will add that name to the list of files to do.  After -x
  8698. X(exclude), the names are removed from the to-do list instead of added.
  8699. X.PP
  8700. XThe pattern matching includes the path, and so patterns like \\*.o match
  8701. Xnames that end in ".o", no matter what the path prefix is.  Note that the
  8702. Xbackslash must precede every special character (i.e. ?*[]), or the entire
  8703. Xargument must be enclosed in double quotes ("").
  8704. X.PP
  8705. XIn general, using backslash to make
  8706. X.I zip
  8707. Xdo the pattern matching is used
  8708. Xwith the -f (freshen) and -d (delete) options, and sometimes after the
  8709. X-x (exclude) option when used with any operation (add, -u, -f, or -d).
  8710. X.I zip
  8711. Xwill never use pattern matching to search the file system.  If
  8712. X.I zip
  8713. Xhas recursed into a directory, all files (and all directories) in there
  8714. Xare fair game.
  8715. X.SH COPYRIGHT
  8716. XCopyright (C) 1990-1992 Mark Adler, Richard B. Wales, Jean-loup Gailly,
  8717. XKai Uwe Rommel and Igor Mandrichenko.
  8718. XPermission is granted to any individual or institution to use, copy, or
  8719. Xredistribute this software so long as all of the original files are included
  8720. Xunmodified, that it is not sold for profit, and that this copyright notice
  8721. Xis retained.
  8722. X.SH ACKNOWLEDGEMENTS
  8723. XThanks to R. P. Byrne for his Shrink.Pas program which inspired this project;
  8724. Xto Phil Katz for making the zip
  8725. Xfile format, compression format, and .zip filename extension all public domain;
  8726. Xto Steve Burg and Phil Katz for help on unclear points of the deflate format;
  8727. Xto Keith Petersen and Rich Wales for providing a mailing list and ftp site for
  8728. Xthe INFO-ZIP group to use; and most importantly, to the INFO-ZIP group itself
  8729. X(listed in the file infozip.who) without whose tireless testing and bug-fixing
  8730. Xefforts a portable
  8731. X.I zip
  8732. Xwould not have been possible.  Finally we should thank (blame) the INFO-ZIP
  8733. Xmoderator, David Kirschbaum for getting us into this mess in the first place.
  8734. X.SH "SEE ALSO"
  8735. Xunzip(1), tar(1), compress(1)
  8736. X.SH BUGS
  8737. XWARNING: zip files produced by zip 1.9 must not be
  8738. X*updated* by zip 1.0 or pkzip 1.10 or pkzip 1.93a, if they contain
  8739. Xencrypted members, or if they have been produced in a pipe or on a non
  8740. Xseekable device. The old versions of zip or pkzip would destroy the
  8741. Xzip structure. The old versions can list the contents of the zip file
  8742. Xbut cannot extract it anyway (because of the new compression algorithm).
  8743. XIf you do not use encryption and use regular disk files, you do
  8744. Xnot have to care about this problem.
  8745. X.PP
  8746. Xzip 1.9 is compatible with pkzip 1.93a, except when two features
  8747. Xare used: encryption or zip file created in a pipe or on a non
  8748. Xseekable device. pkzip versions above 2.0 will support such files, and
  8749. Xunzip 5.0 already supports them.
  8750. X.PP
  8751. XWithout -y, when zip must compress a symbolic link to an non existing file,
  8752. Xit only displays a warning "name not matched". A better warnign should be
  8753. Xgiven.
  8754. X.PP
  8755. XUnder VMS, not all of the odd file formats are treated properly.  Only
  8756. Xzip files of format stream-LF and fixed length 512 are expected to work
  8757. Xwith zip.  Others can be converted using Rahul Dhesi's BILF program.
  8758. XThis version of zip does handle some of the conversion internally.
  8759. XWhen using Kermit to transfer zip files from Vax to MSDOS, type "set
  8760. Xfile type block" on the Vax.  When transfering from MSDOS to Vax, type
  8761. X"set file type fixed" on the Vax.  In both cases, type "set file type
  8762. Xbinary" on MSDOS.
  8763. X.PP
  8764. XUnder VMS, zip hangs for file specification that uses DECnet syntax (foo::*.*).
  8765. X.PP
  8766. XUnder OS/2, the amount of External Attributes displayed by DIR is (for
  8767. Xcompatibility) the amount returned by the 16-bit version of
  8768. XDosQueryPathInfo(). Otherwise OS/2 1.3 and 2.0 would report different
  8769. XEA sizes when DIRing a file.
  8770. XHowever, the structure layout returned by the 32-bit DosQueryPathInfo()
  8771. Xis a bit different, it uses extra padding bytes and link pointers (it's
  8772. Xa linked list) to have all fields on 4-byte boundaries for portability
  8773. Xto future RISC OS/2 versions. Therefore the value reported by ZIP
  8774. X(which uses this 32-bit-mode size) differs from that reported by DIR.
  8775. XZIP stores the 32-bit format for portability, even the 16-bit
  8776. XMS-C-compiled version running on OS/2 1.3, so even this one shows the
  8777. X32-bit-mode size.
  8778. X.PP
  8779. XLIKE ANYTHING ELSE THAT'S FREE, ZIP AND ITS ASSOCIATED UTILITIES ARE
  8780. XPROVIDED AS IS AND COME WITH NO WARRANTY OF ANY KIND, EITHER EXPRESSED OR
  8781. XIMPLIED. IN NO EVENT WILL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES
  8782. XRESULTING FROM THE USE OF THIS SOFTWARE.
  8783. X.PP
  8784. XThat having been said, please send any problems or comments via email to
  8785. Xthe Internet address
  8786. Xzip\-bugs@cs.ucla.edu.  For bug reports, please include the
  8787. Xversion of zip, the make options you used to compile it, the machine and
  8788. Xoperating system you are using, and as much additional information as
  8789. Xpossible.  Thank you for your support.
  8790. END_OF_FILE
  8791.   if test 21796 -ne `wc -c <'zip.1'`; then
  8792.     echo shar: \"'zip.1'\" unpacked with wrong size!
  8793.   fi
  8794.   # end of 'zip.1'
  8795. fi
  8796. if test -f 'zip.h' -a "${1}" != "-c" ; then 
  8797.   echo shar: Will not clobber existing file \"'zip.h'\"
  8798. else
  8799.   echo shar: Extracting \"'zip.h'\" \(10606 characters\)
  8800.   sed "s/^X//" >'zip.h' <<'END_OF_FILE'
  8801. X/*
  8802. X
  8803. X Copyright (C) 1990-1992 Mark Adler, Richard B. Wales, Jean-loup Gailly,
  8804. X Kai Uwe Rommel and Igor Mandrichenko.
  8805. X Permission is granted to any individual or institution to use, copy, or
  8806. X redistribute this software so long as all of the original files are included
  8807. X unmodified, that it is not sold for profit, and that this copyright notice
  8808. X is retained.
  8809. X
  8810. X*/
  8811. X
  8812. X/*
  8813. X *  zip.h by Mark Adler.
  8814. X */
  8815. X
  8816. X
  8817. X/* Set up portability */
  8818. X#include "tailor.h"
  8819. X
  8820. X#define MIN_MATCH  3
  8821. X#define MAX_MATCH  258
  8822. X/* The minimum and maximum match lengths */
  8823. X
  8824. X#ifndef WSIZE
  8825. X#  define WSIZE  ((unsigned)32768)
  8826. X#endif
  8827. X/* Maximum window size = 32K. If you are really short of memory, compile
  8828. X * with a smaller WSIZE but this reduces the compression ratio for files
  8829. X * of size > WSIZE. WSIZE must be a power of two in the current implementation.
  8830. X */
  8831. X
  8832. X#define MIN_LOOKAHEAD (MAX_MATCH+MIN_MATCH+1)
  8833. X/* Minimum amount of lookahead, except at the end of the input file.
  8834. X * See deflate.c for comments about the MIN_MATCH+1.
  8835. X */
  8836. X
  8837. X#define MAX_DIST  (WSIZE-MIN_LOOKAHEAD)
  8838. X/* In order to simplify the code, particularly on 16 bit machines, match
  8839. X * distances are limited to MAX_DIST instead of WSIZE.
  8840. X */
  8841. X
  8842. X/* Define malloc() and string functions */
  8843. X#ifdef MODERN
  8844. X#  include <string.h>
  8845. X#else /* !MODERN */
  8846. X   voidp *malloc();
  8847. X   char *getenv();
  8848. X   long atol();
  8849. X   char *strcpy();
  8850. X   char *strcat();
  8851. X   char *strchr();
  8852. X   char *strrchr();
  8853. X#  ifndef ZMEM
  8854. X     char *memset();
  8855. X     char *memcpy();
  8856. X#  endif /* !ZMEM */
  8857. X#endif /* ?MODERN */
  8858. X
  8859. X
  8860. X/* Define fseek() commands */
  8861. X#ifndef SEEK_SET
  8862. X#  define SEEK_SET 0
  8863. X#endif /* !SEEK_SET */
  8864. X
  8865. X#ifndef SEEK_CUR
  8866. X#  define SEEK_CUR 1
  8867. X#endif /* !SEEK_CUR */
  8868. X
  8869. X
  8870. X/* Forget FILENAME_MAX (incorrectly = 14 on some System V) */
  8871. X#ifdef MSDOS
  8872. X#  define FNMAX 256
  8873. X#else /* !MSDOS */
  8874. X#  define FNMAX 1024
  8875. X#endif /* ?MSDOS */
  8876. X
  8877. X
  8878. X/* For setting stdout to binary */
  8879. X#ifdef MSDOS
  8880. X#  include <io.h>
  8881. X#  include <fcntl.h>
  8882. X#endif /* MSDOS */
  8883. X
  8884. X
  8885. X/* Types centralized here for easy modification */
  8886. X#define local static            /* More meaningful outside functions */
  8887. Xtypedef unsigned char uch;      /* unsigned 8-bit value */
  8888. Xtypedef unsigned short ush;     /* unsigned 16-bit value */
  8889. Xtypedef unsigned long ulg;      /* unsigned 32-bit value */
  8890. X
  8891. X
  8892. X/* Lengths of headers after signatures in bytes */
  8893. X#define LOCHEAD 26
  8894. X#define CENHEAD 42
  8895. X#define ENDHEAD 18
  8896. X
  8897. X
  8898. X/* Structures for in-memory file information */
  8899. Xstruct zlist {
  8900. X  /* See central header in zipfile.c for what vem..off are */
  8901. X  ush vem, ver, flg, how;
  8902. X  ulg tim, crc, siz, len;
  8903. X  extent nam, ext, cext, com;   /* offset of ext must be >= LOCHEAD */
  8904. X  ush dsk, att, lflg;           /* offset of lflg must be >= LOCHEAD */
  8905. X  ulg atx, off;
  8906. X  char *name;                   /* File name in zip file */
  8907. X  char *extra;                  /* Extra field (set only if ext != 0) */
  8908. X  char *cextra;                 /* Extra in central (set only if cext != 0) */
  8909. X  char *comment;                /* Comment (set only if com != 0) */
  8910. X  char *zname;                  /* Name for new zip file header */
  8911. X  int mark;                     /* Marker for files to operate on */
  8912. X  int trash;                    /* Marker for files to delete */
  8913. X  int dosflag;                  /* Set to force MSDOS file attributes */
  8914. X  struct zlist far *nxt;        /* Pointer to next header in list */
  8915. X};
  8916. Xstruct flist {
  8917. X  char *name;                   /* Pointer to zero-delimited name */
  8918. X  char *zname;                  /* Name used for zip file headers */
  8919. X  int dosflag;                  /* Set to force MSDOS file attributes */
  8920. X  struct flist far * far *lst;  /* Pointer to link pointing here */
  8921. X  struct flist far *nxt;        /* Link to next name */
  8922. X};
  8923. X
  8924. X/* internal file attribute */
  8925. X#define UNKNOWN (-1)
  8926. X#define BINARY  0
  8927. X#define ASCII   1
  8928. X
  8929. X/* Error return codes and PERR macro */
  8930. X#include "ziperr.h"
  8931. X
  8932. X
  8933. X/* Public globals */
  8934. Xextern uch upper[256];          /* Country dependent case map table */
  8935. Xextern uch lower[256];
  8936. Xextern char errbuf[];           /* Handy place to build error messages */
  8937. Xextern int recurse;             /* Recurse into directories encountered */
  8938. Xextern int pathput;             /* Store path with name */
  8939. X
  8940. X#define BEST -1                 /* Use best method (deflation or store) */
  8941. X#define STORE 0                 /* Store method */
  8942. X#define DEFLATE 8               /* Deflation method*/
  8943. Xextern int method;              /* Restriction on compression method */
  8944. X
  8945. Xextern int dosify;              /* Make new entries look like MSDOS */
  8946. Xextern char *special;           /* Don't compress special suffixes */
  8947. Xextern int verbose;             /* Report oddities in zip file structure */
  8948. Xextern int level;               /* Compression level */
  8949. Xextern int translate_eol;       /* Translate end-of-line LF -> CR LF */
  8950. X#ifdef VMS
  8951. X   extern int vmsver;           /* Append VMS version number to file names */
  8952. X   extern int vms_native;       /* Store in VMS formait */
  8953. X#endif /* VMS */
  8954. X#ifdef OS2
  8955. X   extern int use_longname_ea;   /* use the .LONGNAME EA as the file's name */
  8956. X#endif /* OS2 */
  8957. Xextern int linkput;             /* Store symbolic links as such */
  8958. Xextern int noisy;               /* False for quiet operation */
  8959. Xextern char *key;               /* Scramble password or NULL */
  8960. Xextern char *tempath;           /* Path for temporary files */
  8961. Xextern FILE *mesg;              /* Where informational output goes */
  8962. Xextern char *zipfile;           /* New or existing zip archive (zip file) */
  8963. Xextern ulg zipbeg;              /* Starting offset of zip structures */
  8964. Xextern ulg cenbeg;              /* Starting offset of central directory */
  8965. Xextern struct zlist far *zfiles;/* Pointer to list of files in zip file */
  8966. Xextern extent zcount;           /* Number of files in zip file */
  8967. Xextern extent zcomlen;          /* Length of zip file comment */
  8968. Xextern char *zcomment;          /* Zip file comment (not zero-terminated) */
  8969. Xextern struct zlist far **zsort;/* List of files sorted by name */
  8970. Xextern ulg tempzn;              /* Count of bytes written to output zip file */
  8971. Xextern struct flist far *found; /* List of names found */
  8972. Xextern struct flist far * far *fnxt;    /* Where to put next in found list */
  8973. Xextern extent fcount;           /* Count of names in found list */
  8974. X
  8975. X
  8976. X/* Diagnostic functions */
  8977. X#ifdef DEBUG
  8978. X# ifdef MSDOS
  8979. X#  undef  stderr
  8980. X#  define stderr stdout
  8981. X# endif
  8982. X#  define diag(where) fprintf(stderr, "zip diagnostic: %s\n", where)
  8983. X#  define Assert(cond,msg) {if(!(cond)) error(msg);}
  8984. X#  define Trace(x) fprintf x
  8985. X#  define Tracev(x) {if (verbose) fprintf x ;}
  8986. X#  define Tracevv(x) {if (verbose>1) fprintf x ;}
  8987. X#  define Tracec(c,x) {if (verbose && (c)) fprintf x ;}
  8988. X#  define Tracecv(c,x) {if (verbose>1 && (c)) fprintf x ;}
  8989. X#else
  8990. X#  define diag(where)
  8991. X#  define Assert(cond,msg)
  8992. X#  define Trace(x)
  8993. X#  define Tracev(x)
  8994. X#  define Tracevv(x)
  8995. X#  define Tracec(c,x)
  8996. X#  define Tracecv(c,x)
  8997. X#endif
  8998. X
  8999. X
  9000. X/* Public function prototypes */
  9001. X
  9002. X        /* in zip.c, zipcloak.c, or zipsplit.c */
  9003. Xvoid warn  OF((char *, char *));
  9004. Xvoid err   OF((int c, char *h));
  9005. Xvoid error OF((char *h));
  9006. X
  9007. X        /* in zipup.c */
  9008. Xint zipcopy OF((struct zlist far *, FILE *, FILE *));
  9009. X#ifndef UTIL
  9010. X   int percent OF((long, long));
  9011. X   int zipup OF((struct zlist far *, FILE *));
  9012. X   int file_read OF((char *buf, unsigned size));
  9013. X#endif /* !UTIL */
  9014. X
  9015. X        /* in zipfile.c */
  9016. X#ifndef UTIL
  9017. X   struct zlist far *zsearch OF((char *));
  9018. X   int trash OF((void));
  9019. X#endif /* !UTIL */
  9020. Xchar *ziptyp OF((char *));
  9021. Xint readzipfile OF((void));
  9022. Xint putlocal OF((struct zlist far *, FILE *));
  9023. Xint putextended OF((struct zlist far *, FILE *));
  9024. Xint putcentral OF((struct zlist far *, FILE *));
  9025. Xint putend OF((int, ulg, ulg, extent, char *, FILE *));
  9026. X
  9027. X        /* in fileio.c */
  9028. X#ifndef UTIL
  9029. X#  ifdef MSDOS
  9030. X     int wild OF((char *));
  9031. X#  endif /* MSDOS */
  9032. X#  ifdef VMS
  9033. X     int wild OF((char *));
  9034. X#  endif /* VMS */
  9035. X   char *getnam OF((char *));
  9036. X   struct flist far *fexpel OF((struct flist far *));
  9037. X   char *in2ex OF((char *));
  9038. X   int exclude OF((void));
  9039. X   int procname OF((char *));
  9040. X   void stamp OF((char *, ulg));
  9041. X   ulg dostime OF((int, int, int, int, int, int));
  9042. X   ulg filetime OF((char *, ulg *, long *));
  9043. X   int issymlnk OF((ulg a));
  9044. X#  ifdef S_IFLNK
  9045. X#    define rdsymlnk(p,b,n) readlink(p,b,n)
  9046. X     extern int readlink OF((char *, char *, int));
  9047. X#  else /* !S_IFLNK */
  9048. X#    define rdsymlnk(p,b,n) (0)
  9049. X#  endif /* !S_IFLNK */
  9050. X   int deletedir OF((char *));
  9051. X#endif /* !UTIL */
  9052. Xint destroy OF((char *));
  9053. Xint replace OF((char *, char *));
  9054. Xint getfileattr OF((char *));
  9055. Xint setfileattr OF((char *, int));
  9056. Xchar *tempname OF((char *));
  9057. Xint fcopy OF((FILE *, FILE *, ulg));
  9058. X#ifdef CRYPT
  9059. X#  ifndef MSVMS
  9060. X     void echoff OF((int));
  9061. X     void echon OF((void));
  9062. X#  endif /* !MSVMS */
  9063. X   char *getp OF((char *, char *, int));
  9064. X#endif /* !CRYPT */
  9065. X#ifdef ZMEM
  9066. X   char *memset OF((char *, int, unsigned int));
  9067. X   char *memcpy OF((char *, char *, unsigned int));
  9068. X   int memcmp OF((char *, char *, unsigned int));
  9069. X#endif /* ZMEM */
  9070. X
  9071. X        /* in crypt.c */
  9072. X#ifndef CRYPT
  9073. X#  define zfwrite fwrite
  9074. X#  define zputc putc
  9075. X#else /* CRYPT */
  9076. X   void crypthead OF((char *, ulg, FILE *));
  9077. X#  ifdef UTIL
  9078. X     int zipcloak OF ((struct zlist far *, FILE *, FILE *, char *));
  9079. X     int zipbare OF ((struct zlist far *, FILE *, FILE *, char *));
  9080. X#  else /* !UTIL */
  9081. X     unsigned zfwrite OF((voidp *, extent, extent, FILE *));
  9082. X     int zencode OF((int c));
  9083. X     extern char *key;
  9084. X#    define zputc(c,f) (putc(key!=NULL? zencode(c) : (c),(f)))
  9085. X#  endif /* ?UTIL */
  9086. X#endif /* ?CRYPT */
  9087. X
  9088. X        /* in util.c */
  9089. Xchar *isshexp OF((char *));
  9090. Xint   shmatch OF((char *, char *));
  9091. X#ifdef MSDOS
  9092. X   int dosmatch OF((char *, char *));
  9093. X#endif /* MSDOS */
  9094. Xvoid     init_upper OF((void));
  9095. Xint      namecmp    OF((char *string1, char *string2));
  9096. Xvoidp far **search  OF((voidp *, voidp far **, extent,
  9097. X                       int (*)(voidp *, voidp far *)));
  9098. Xulg crc32 OF((ulg, int));
  9099. Xulg updcrc OF((char *, extent));
  9100. X
  9101. X#ifndef UTIL
  9102. X        /* in deflate.c */
  9103. Xvoid lm_init OF((int pack_level, ush *flags));
  9104. Xulg  deflate OF((void));
  9105. X
  9106. X        /* in trees.c */
  9107. Xvoid ct_init     OF((ush *attr, int *method));
  9108. Xint  ct_tally    OF((int dist, int lc));
  9109. Xulg  flush_block OF((char far *buf, ulg stored_len, int eof));
  9110. X
  9111. X        /* in bits.c */
  9112. Xvoid     bi_init    OF((FILE *zipfile));
  9113. Xvoid     send_bits  OF((int value, int length));
  9114. Xunsigned bi_reverse OF((unsigned value, int length));
  9115. Xvoid     bi_windup  OF((void));
  9116. Xvoid     copy_block OF((char far *buf, unsigned len, int header));
  9117. Xint      seekable   OF((void));
  9118. Xextern   int (*read_buf) OF((char *buf, unsigned size));
  9119. Xulg     memcompress OF((char *tgt, ulg tgtsize, char *src, ulg srcsize));
  9120. X
  9121. X#endif /* !UTIL */
  9122. X
  9123. X
  9124. X/* end of zip.h */
  9125. END_OF_FILE
  9126.   if test 10606 -ne `wc -c <'zip.h'`; then
  9127.     echo shar: \"'zip.h'\" unpacked with wrong size!
  9128.   fi
  9129.   # end of 'zip.h'
  9130. fi
  9131. if test -f 'zipfile.c' -a "${1}" != "-c" ; then 
  9132.   echo shar: Will not clobber existing file \"'zipfile.c'\"
  9133. else
  9134.   echo shar: Extracting \"'zipfile.c'\" \(24578 characters\)
  9135.   sed "s/^X//" >'zipfile.c' <<'END_OF_FILE'
  9136. X/*
  9137. X
  9138. X Copyright (C) 1990-1992 Mark Adler, Richard B. Wales, Jean-loup Gailly,
  9139. X Kai Uwe Rommel and Igor Mandrichenko.
  9140. X Permission is granted to any individual or institution to use, copy, or
  9141. X redistribute this software so long as all of the original files are included
  9142. X unmodified, that it is not sold for profit, and that this copyright notice
  9143. X is retained.
  9144. X
  9145. X*/
  9146. X
  9147. X/*
  9148. X *  zipfile.c by Mark Adler.
  9149. X */
  9150. X
  9151. X#include "zip.h"
  9152. X
  9153. X#ifdef VMS
  9154. X#  include "VMSmunch.h"
  9155. X#  include <rms.h>
  9156. X#endif
  9157. X
  9158. X
  9159. X/* Macros for converting integers in little-endian to machine format */
  9160. X#define SH(a) (((ush)(uch)(a)[0]) | (((ush)(uch)(a)[1]) << 8))
  9161. X#define LG(a) ((ulg)SH(a) | ((ulg)SH((a)+2) << 16))
  9162. X
  9163. X/* Macros for writing machine integers to little-endian format */
  9164. X#define PUTSH(a,f) {putc((char)(a),(f)); putc((char)((a) >> 8),(f));}
  9165. X#define PUTLG(a,f) {PUTSH(a,f) PUTSH((a) >> 16,f)}
  9166. X
  9167. X
  9168. X/* -- Structure of a ZIP file -- */
  9169. X
  9170. X/* Signatures for zip file information headers */
  9171. X#define LOCSIG     0x04034b50L
  9172. X#define CENSIG     0x02014b50L
  9173. X#define ENDSIG     0x06054b50L
  9174. X#define EXTLOCSIG  0x08074b50L
  9175. X
  9176. X/* Offsets of values in headers */
  9177. X#define LOCVER  0               /* version needed to extract */
  9178. X#define LOCFLG  2               /* encrypt, deflate flags */
  9179. X#define LOCHOW  4               /* compression method */
  9180. X#define LOCTIM  6               /* last modified file time, DOS format */
  9181. X#define LOCDAT  8               /* last modified file date, DOS format */
  9182. X#define LOCCRC  10              /* uncompressed crc-32 for file */
  9183. X#define LOCSIZ  14              /* compressed size in zip file */
  9184. X#define LOCLEN  18              /* uncompressed size */
  9185. X#define LOCNAM  22              /* length of filename */
  9186. X#define LOCEXT  24              /* length of extra field */
  9187. X
  9188. X#define CENVEM  0               /* version made by */
  9189. X#define CENVER  2               /* version needed to extract */
  9190. X#define CENFLG  4               /* encrypt, deflate flags */
  9191. X#define CENHOW  6               /* compression method */
  9192. X#define CENTIM  8               /* last modified file time, DOS format */
  9193. X#define CENDAT  10              /* last modified file date, DOS format */
  9194. X#define CENCRC  12              /* uncompressed crc-32 for file */
  9195. X#define CENSIZ  16              /* compressed size in zip file */
  9196. X#define CENLEN  20              /* uncompressed size */
  9197. X#define CENNAM  24              /* length of filename */
  9198. X#define CENEXT  26              /* length of extra field */
  9199. X#define CENCOM  28              /* file comment length */
  9200. X#define CENDSK  30              /* disk number start */
  9201. X#define CENATT  32              /* internal file attributes */
  9202. X#define CENATX  34              /* external file attributes */
  9203. X#define CENOFF  38              /* relative offset of local header */
  9204. X
  9205. X#define ENDDSK  0               /* number of this disk */
  9206. X#define ENDBEG  2               /* number of the starting disk */
  9207. X#define ENDSUB  4               /* entries on this disk */
  9208. X#define ENDTOT  6               /* total number of entries */
  9209. X#define ENDSIZ  8               /* size of entire central directory */
  9210. X#define ENDOFF  12              /* offset of central on starting disk */
  9211. X#define ENDCOM  16              /* length of zip file comment */
  9212. X
  9213. X
  9214. X/* Local functions */
  9215. X#ifdef PROTO
  9216. X   local int zqcmp(voidp *, voidp *);
  9217. X#  ifndef UTIL
  9218. X     local int zbcmp(voidp *, voidp far *);
  9219. X     local char *cutpath(char *);
  9220. X#  endif /* !UTIL */
  9221. X#endif /* PROTO */
  9222. X
  9223. X
  9224. Xlocal int zqcmp(a, b)
  9225. Xvoidp *a, *b;           /* pointers to pointers to zip entries */
  9226. X/* Used by qsort() to compare entries in the zfile list.  */
  9227. X{
  9228. X  return namecmp((*(struct zlist far **)a)->zname,
  9229. X                (*(struct zlist far **)b)->zname);
  9230. X}
  9231. X
  9232. X
  9233. X#ifndef UTIL
  9234. X
  9235. Xlocal int zbcmp(n, z)
  9236. Xvoidp *n;               /* string to search for */
  9237. Xvoidp far *z;           /* pointer to a pointer to a zip entry */
  9238. X/* Used by search() to compare a target to an entry in the zfile list. */
  9239. X{
  9240. X  return namecmp((char *)n, ((struct zlist far *)z)->zname);
  9241. X}
  9242. X
  9243. X
  9244. Xstruct zlist far *zsearch(n)
  9245. Xchar *n;                /* name to find */
  9246. X/* Return a pointer to the entry in zfile with the name n, or NULL if
  9247. X   not found. */
  9248. X{
  9249. X  voidp far **p;        /* result of search() */
  9250. X
  9251. X  if (zcount && (p = search(n, (voidp far **)zsort, zcount, zbcmp)) != NULL)
  9252. X    return *(struct zlist far **)p;
  9253. X  else
  9254. X    return NULL;
  9255. X}
  9256. X
  9257. X#endif /* !UTIL */
  9258. X
  9259. X#ifndef VMS
  9260. X#  define PATHCUT '/'
  9261. X
  9262. Xchar *ziptyp(s)
  9263. Xchar *s;                /* file name to force to zip */
  9264. X/* If the file name *s has a dot (other than the first char), then return
  9265. X   the name, otherwise append .zip to the name.  Allocate the space for
  9266. X   the name in either case.  Return a pointer to the new name, or NULL
  9267. X   if malloc() fails. */
  9268. X{
  9269. X  char *q;              /* temporary pointer */
  9270. X  char *t;              /* pointer to malloc'ed string */
  9271. X
  9272. X  if ((t = malloc(strlen(s) + 5)) == NULL)
  9273. X    return NULL;
  9274. X  strcpy(t, s);
  9275. X#ifdef MSDOS
  9276. X  for (q = t; *q; q++)
  9277. X    if (*q == '\\')
  9278. X      *q = '/';
  9279. X#endif /* MSDOS */
  9280. X  if (strrchr((q = strrchr(t, PATHCUT)) == NULL ? t : q + 1, '.') == NULL)
  9281. X    strcat(t, ".zip");
  9282. X#if defined(FORCE_UPPER) && defined(MSDOS) && !defined(OS2)
  9283. X  strupr(t);
  9284. X#endif
  9285. X  return t;
  9286. X}
  9287. X
  9288. X#else /* VMS */
  9289. X
  9290. X# define PATHCUT ']'
  9291. X
  9292. Xchar *ziptyp(s)
  9293. Xchar *s;
  9294. X{   int status;
  9295. X    struct FAB fab;
  9296. X    struct NAM nam;
  9297. X    static char zero=0;
  9298. X    char result[NAM$C_MAXRSS+1],exp[NAM$C_MAXRSS+1];
  9299. X    char *p;
  9300. X
  9301. X    fab = cc$rms_fab;
  9302. X    nam = cc$rms_nam;
  9303. X
  9304. X    fab.fab$l_fna = s;
  9305. X    fab.fab$b_fns = strlen(fab.fab$l_fna);
  9306. X
  9307. X    fab.fab$l_dna = "sys$disk:[].zip";          /* Default fspec */
  9308. X    fab.fab$b_dns = strlen(fab.fab$l_dna);
  9309. X
  9310. X    fab.fab$l_nam = &nam;
  9311. X    
  9312. X    nam.nam$l_rsa = result;                     /* Put resultant name of */
  9313. X    nam.nam$b_rss = sizeof(result)-1;           /* existing zipfile here */
  9314. X
  9315. X    nam.nam$l_esa = exp;                        /* For full spec of */
  9316. X    nam.nam$b_ess = sizeof(exp)-1;              /* file to create */
  9317. X
  9318. X    status = sys$parse(&fab);
  9319. X    if( (status & 1) == 0 )
  9320. X        return &zero;
  9321. X
  9322. X    status = sys$search(&fab);
  9323. X    if( status & 1 )
  9324. X    {               /* Existing ZIP file */
  9325. X        int l;
  9326. X        if( (p=malloc( (l=nam.nam$b_rsl) + 1 )) != NULL )
  9327. X        {       result[l] = 0;
  9328. X                strcpy(p,result);
  9329. X        }
  9330. X    }
  9331. X    else
  9332. X    {               /* New ZIP file */
  9333. X        int l;
  9334. X        if( (p=malloc( (l=nam.nam$b_esl) + 1 )) != NULL )
  9335. X        {       exp[l] = 0;
  9336. X                strcpy(p,exp);
  9337. X        }
  9338. X    }
  9339. X    return p;
  9340. X}
  9341. X
  9342. X#endif  /* VMS */
  9343. X
  9344. X
  9345. Xint readzipfile()
  9346. X/*
  9347. X   Make first pass through zip file, reading information from local file
  9348. X   headers and then verifying that information with the central file
  9349. X   headers.  Any deviation from the expected zip file format returns an
  9350. X   error.  At the end, a sorted list of file names in the zip file is made
  9351. X   to facilitate searching by name.
  9352. X
  9353. X   The name of the zip file is pointed to by the global "zipfile".  The
  9354. X   globals zfiles, zcount, zcomlen, zcomment, and zsort are filled in.
  9355. X   Return an error code in the ZE_ class.
  9356. X*/
  9357. X{
  9358. X  char b[CENHEAD];      /* buffer for central headers */
  9359. X  FILE *f;              /* zip file */
  9360. X  ush flg;              /* general purpose bit flag */
  9361. X  int m;                /* mismatch flag */
  9362. X  extent n;             /* length of name */
  9363. X  ulg p;                /* current file offset */
  9364. X  char r;               /* holds reserved bits during memcmp() */
  9365. X  ulg s;                /* size of data, start of central */
  9366. X  char *t;              /* temporary variable */
  9367. X  char far *u;          /* temporary variable */
  9368. X  struct zlist far * far *x;    /* pointer last entry's link */
  9369. X  struct zlist far *z;  /* current zip entry structure */
  9370. X
  9371. X  /* Initialize zip file info */
  9372. X  zipbeg = 0;
  9373. X  zfiles = NULL;                        /* Points to first header */
  9374. X  zcomlen = 0;                          /* zip file comment length */
  9375. X
  9376. X  /* If zip file exists, read headers and check structure */
  9377. X#ifdef VMS
  9378. X  if (zipfile == NULL || !(*zipfile) || !strcmp(zipfile, "-"))
  9379. X    return ZE_OK;
  9380. X  {
  9381. X    int rtype;
  9382. X    VMSmunch(zipfile, GET_RTYPE, (char *)&rtype);
  9383. X    if (rtype == FAT$C_VARIABLE) {
  9384. X      fprintf(stderr,
  9385. X     "\n     Error:  zipfile is in variable-length record format.  Please\n\
  9386. X     run \"bilf b %s\" to convert the zipfile to fixed-length\n\
  9387. X     record format.  (Bilf.exe, bilf.c and make_bilf.com are included\n\
  9388. X     in the VMS UnZip distribution.)\n\n", zipfile);
  9389. X      return ZE_FORM;
  9390. X    }
  9391. X  }
  9392. X  if ((f = fopen(zipfile, FOPR)) != NULL)
  9393. X#else /* !VMS */
  9394. X  if (zipfile != NULL && *zipfile && strcmp(zipfile, "-") &&
  9395. X      (f = fopen(zipfile, FOPR)) != NULL)
  9396. X#endif /* ?VMS */
  9397. X  {
  9398. X    x = &zfiles;                        /* first link */
  9399. X    p = 0;                              /* starting file offset */
  9400. X    zcount = 0;                         /* number of files */
  9401. X
  9402. X    /* Find start of zip structures */
  9403. X    for (;;) {
  9404. X      while ((m = getc(f)) != EOF && m != 'P') p++;
  9405. X      b[0] = (char) m;
  9406. X      if (fread(b+1, 3, 1, f) != 1 || (s = LG(b)) == LOCSIG || s == ENDSIG)
  9407. X        break;
  9408. X      if (fseek(f, -3L, SEEK_CUR))
  9409. X        return ferror(f) ? ZE_READ : ZE_EOF;
  9410. X      p++;
  9411. X    }
  9412. X    zipbeg = p;
  9413. X
  9414. X    /* Read local headers */
  9415. X    while (LG(b) == LOCSIG)
  9416. X    {
  9417. X      /* Read local header raw to compare later with central header
  9418. X         (this requires that the offest of ext in the zlist structure
  9419. X         be greater than or equal to LOCHEAD) */
  9420. X      if ((z = (struct zlist far *)farmalloc(sizeof(struct zlist))) == NULL)
  9421. X        return ZE_MEM;
  9422. X      if (fread(b, LOCHEAD, 1, f) != 1)
  9423. X        return ferror(f) ? ZE_READ : ZE_EOF;
  9424. X      t = b;  u = (char far *)z;  n = LOCHEAD;
  9425. X      do {
  9426. X        *u++ = *t++;
  9427. X      } while (--n);
  9428. X
  9429. X      /* Link into list */
  9430. X      *x = z;
  9431. X      z->nxt = NULL;
  9432. X      x = &z->nxt;
  9433. X
  9434. X      /* Read file name and extra field and skip data */
  9435. X      n = SH(LOCNAM + (uch far *)z);
  9436. X      z->ext = SH(LOCEXT + (uch far *)z);
  9437. X      s = LG(LOCSIZ + (uch far *)z);
  9438. X      if (n == 0)
  9439. X      {
  9440. X        sprintf(errbuf, "%d", zcount + 1);
  9441. X        warn("zero-length name for entry #", errbuf);
  9442. X        return ZE_FORM;
  9443. X      }
  9444. X      if ((z->zname = malloc(n+1)) ==  NULL ||
  9445. X          (z->ext && (z->extra = malloc(z->ext)) == NULL))
  9446. X        return ZE_MEM;
  9447. X      if (fread(z->zname, n, 1, f) != 1 ||
  9448. X          (z->ext && fread(z->extra, z->ext, 1, f) != 1) ||
  9449. X          fseek(f, (long)s, SEEK_CUR))
  9450. X        return ferror(f) ? ZE_READ : ZE_EOF;
  9451. X      /* If there is an extended local header, s is either 0 or
  9452. X       * the correct compressed size.
  9453. X       */
  9454. X      z->zname[n] = 0;                  /* terminate name */
  9455. X#ifdef UTIL
  9456. X      z->name = z->zname;
  9457. X#else /* !UTIL */
  9458. X      z->name = in2ex(z->zname);        /* convert to external name */
  9459. X      if (z->name == NULL)
  9460. X        return ZE_MEM;
  9461. X#endif /* ?UTIL */
  9462. X
  9463. X      /* Save offset, update for next header */
  9464. X      z->off = p;
  9465. X      p += 4 + LOCHEAD + n + z->ext + s;
  9466. X      zcount++;
  9467. X
  9468. X      /* Skip extended local header if there is one */
  9469. X      flg = SH(b+LOCFLG);
  9470. X      if ((flg & 8) != 0) {
  9471. X        /* Skip the compressed data if compressed size is unknown.
  9472. X         * For safety, we should use the central directory.
  9473. X         */
  9474. X        if (s == 0) {
  9475. X          for (;;) {
  9476. X            while ((m = getc(f)) != EOF && m != 'P') ;
  9477. X            b[0] = (char) m;
  9478. X            if (fread(b+1, 15, 1, f) != 1 || LG(b) == EXTLOCSIG)
  9479. X              break;
  9480. X            if (fseek(f, -15L, SEEK_CUR))
  9481. X              return ferror(f) ? ZE_READ : ZE_EOF;
  9482. X          }
  9483. X          s = LG(b+8);
  9484. X          p += s;
  9485. X          if ((ulg) ftell(f) != p+16L) {
  9486. X            warn("bad extended local header for ", z->zname);
  9487. X            return ZE_FORM;
  9488. X          }
  9489. X        } else {
  9490. X          /* compressed size non zero, assume that it is valid: */
  9491. X          if (fseek(f, p, SEEK_SET) || fread(b, 16, 1, f) != 1)
  9492. X            return ferror(f) ? ZE_READ : ZE_EOF;
  9493. X          if (LG(b) != EXTLOCSIG) {
  9494. X            warn("extended local header not found for ", z->zname);
  9495. X            return ZE_FORM;
  9496. X          }
  9497. X        }
  9498. X        /* overwrite the unknown values of the local header: */
  9499. X        t = b+4;  u = (char far *)z+LOCCRC;  n = 12;
  9500. X        do {
  9501. X          *u++ = *t++;
  9502. X        } while (--n);
  9503. X        p += 16L;
  9504. X      }
  9505. X      /* Read next signature */
  9506. X      if (fread(b, 4, 1, f) != 1)
  9507. X        return ferror(f) ? ZE_READ : ZE_EOF;
  9508. X    }
  9509. X
  9510. X    /* Point to start of header list and read central headers */
  9511. X    z = zfiles;
  9512. X    s = p;                              /* save start of central */
  9513. X    while (LG(b) == CENSIG)
  9514. X    {
  9515. X      if (z == NULL)
  9516. X      {
  9517. X        warn("extraneous central header signature", "");
  9518. X        return ZE_FORM;
  9519. X      }
  9520. X
  9521. X      /* Read central header */
  9522. X      if (fread(b, CENHEAD, 1, f) != 1)
  9523. X        return ferror(f) ? ZE_READ : ZE_EOF;
  9524. X
  9525. X      /* Compare local header with that part of central header (except
  9526. X         for the reserved bits in the general purpose flags and except
  9527. X         for length of extra fields--authentication can make these
  9528. X         different in central and local headers) */
  9529. X      z->lflg = SH(LOCFLG + (uch far *)z);      /* Save reserved bits */
  9530. X      r = b[CENFLG+1];
  9531. X      ((uch far *)z)[LOCFLG+1] &= 0x1f; /* Zero out reserved bits */
  9532. X      b[CENFLG+1] &= 0x1f;
  9533. X      for (m = 0, u = (char far *)z, n = 0; n < LOCHEAD - 2; n++)
  9534. X        if (u[n] != b[n+2])
  9535. X        {
  9536. X          if (!m)
  9537. X            warn("local and central headers differ for ", z->zname);
  9538. X          m = 1;
  9539. X          sprintf(errbuf, " offset %d--local = %02x, central = %02x",
  9540. X                  n, (uch)u[n], (uch)b[n+2]);
  9541. X          warn(errbuf, "");
  9542. X        }
  9543. X      if (m)
  9544. X        return ZE_FORM;
  9545. X      b[CENFLG+1] = r;                  /* Restore reserved bits */
  9546. X
  9547. X      /* Overwrite local header with translated central header */
  9548. X      z->vem = SH(CENVEM + b);
  9549. X      z->ver = SH(CENVER + b);
  9550. X      z->flg = SH(CENFLG + b);          /* may be different from z->lflg */
  9551. X      z->how = SH(CENHOW + b);
  9552. X      z->tim = LG(CENTIM + b);          /* time and date into one long */
  9553. X      z->crc = LG(CENCRC + b);
  9554. X      z->siz = LG(CENSIZ + b);
  9555. X      z->len = LG(CENLEN + b);
  9556. X      z->nam = SH(CENNAM + b);
  9557. X      z->cext = SH(CENEXT + b);         /* may be different from z->ext */
  9558. X      z->com = SH(CENCOM + b);
  9559. X      z->dsk = SH(CENDSK + b);
  9560. X      z->att = SH(CENATT + b);
  9561. X      z->atx = LG(CENATX + b);
  9562. X      if (z->off != LG(CENOFF + b))
  9563. X      {
  9564. X        warn("local offset in central header incorrect for ", z->zname);
  9565. X        return ZE_FORM;
  9566. X      }
  9567. X
  9568. X      /* Compare name and extra fields and read comment field */
  9569. X      if ((t = malloc(z->nam)) == NULL)
  9570. X        return ZE_MEM;
  9571. X      if (fread(t, z->nam, 1, f) != 1)
  9572. X      {
  9573. X        free((voidp *)t);
  9574. X        return ferror(f) ? ZE_READ : ZE_EOF;
  9575. X      }
  9576. X      if (memcmp(t, z->zname, z->nam))
  9577. X      {
  9578. X        free((voidp *)t);
  9579. X        warn("names in local and central differ for ", z->zname);
  9580. X        return ZE_FORM;
  9581. X      }
  9582. X      free((voidp *)t);
  9583. X      if (z->cext)
  9584. X      {
  9585. X        if ((z->cextra = malloc(z->cext)) == NULL)
  9586. X          return ZE_MEM;
  9587. X        if (fread(z->cextra, z->cext, 1, f) != 1)
  9588. X        {
  9589. X          free((voidp *)(z->cextra));
  9590. X          return ferror(f) ? ZE_READ : ZE_EOF;
  9591. X        }
  9592. X        if (z->ext == z->cext && memcmp(z->extra, z->cextra, z->ext) == 0)
  9593. X        {
  9594. X          free((voidp *)(z->cextra));
  9595. X          z->cextra = z->extra;
  9596. X        }
  9597. X      }
  9598. X      if (z->com)
  9599. X      {
  9600. X        if ((z->comment = malloc(z->com)) == NULL)
  9601. X          return ZE_MEM;
  9602. X        if (fread(z->comment, z->com, 1, f) != 1)
  9603. X        {
  9604. X          free((voidp *)(z->comment));
  9605. X          return ferror(f) ? ZE_READ : ZE_EOF;
  9606. X        }
  9607. X      }
  9608. X
  9609. X      /* Note oddities */
  9610. X      if (verbose)
  9611. X      {
  9612. X        if (z->vem != 10 && z->vem != 11 && z->vem != 20 &&
  9613. X            (n = z->vem >> 8) != 3 && n != 2 && n != 6 && n != 0)
  9614. X        {
  9615. X          sprintf(errbuf, "made by version %d.%d on system type %d: ",
  9616. X            (ush)(z->vem & 0xff) / (ush)10,
  9617. X            (ush)(z->vem & 0xff) % (ush)10, z->vem >> 8);
  9618. X          warn(errbuf, z->zname);
  9619. X        }
  9620. X        if (z->ver != 10 && z->ver != 11 && z->ver != 20)
  9621. X        {
  9622. X          sprintf(errbuf, "needs unzip %d.%d on system type %d: ",
  9623. X            (ush)(z->ver & 0xff) / (ush)10,
  9624. X            (ush)(z->ver & 0xff) % (ush)10, z->ver >> 8);
  9625. X          warn(errbuf, z->zname);
  9626. X        }
  9627. X        if (z->flg != z->lflg)
  9628. X        {
  9629. X          sprintf(errbuf, "local flags = 0x%04x, central = 0x%04x: ",
  9630. X                  z->lflg, z->flg);
  9631. X          warn(errbuf, z->zname);
  9632. X        }
  9633. X        else if (z->flg & ~0xf)
  9634. X        {
  9635. X          sprintf(errbuf, "undefined bits used in flags = 0x%04x: ", z->flg);
  9636. X          warn(errbuf, z->zname);
  9637. X        }
  9638. X        if (z->how > DEFLATE)
  9639. X        {
  9640. X          sprintf(errbuf, "unknown compression method %u: ", z->how);
  9641. X          warn(errbuf, z->zname);
  9642. X        }
  9643. X        if (z->dsk)
  9644. X        {
  9645. X          sprintf(errbuf, "starts on disk %u: ", z->dsk);
  9646. X          warn(errbuf, z->zname);
  9647. X        }
  9648. X        if (z->att & ~1)
  9649. X        {
  9650. X          sprintf(errbuf, "unknown internal attributes = 0x%04x: ", z->att);
  9651. X          warn(errbuf, z->zname);
  9652. X        }
  9653. X        if (((n = z->vem >> 8) != 3) && n != 2 && z->atx & ~0xffL)
  9654. X        {
  9655. X          sprintf(errbuf, "unknown external attributes = 0x%08lx: ", z->atx);
  9656. X          warn(errbuf, z->zname);
  9657. X        }
  9658. X        if (z->ext || z->cext)
  9659. X          if (z->ext == z->cext && z->extra == z->cextra)
  9660. X          {
  9661. X            sprintf(errbuf, "has %d bytes of extra data: ", z->ext);
  9662. X            warn(errbuf, z->zname);
  9663. X          }
  9664. X          else
  9665. X          {
  9666. X            sprintf(errbuf,
  9667. X                    "local extra (%d bytes) != central extra (%d bytes): ",
  9668. X                    z->ext, z->cext);
  9669. X            warn(errbuf, z->zname);
  9670. X          }
  9671. X      }
  9672. X
  9673. X      /* Clear actions */
  9674. X      z->mark = 0;
  9675. X      z->trash = 0;
  9676. X
  9677. X      /* Update file offset */
  9678. X      p += 4 + CENHEAD + z->nam + z->cext + z->com;
  9679. X
  9680. X      /* Advance to next header structure */
  9681. X      z = z->nxt;
  9682. X
  9683. X      /* Read next signature */
  9684. X      if (fread(b, 4, 1, f) != 1)
  9685. X        return ferror(f) ? ZE_READ : ZE_EOF;
  9686. X    }
  9687. X    
  9688. X    /* Read end header */
  9689. X    if (z != NULL || LG(b) != ENDSIG)
  9690. X    {
  9691. X      warn("missing end signature--probably not a zip file (did you", "");
  9692. X      warn("remember to use binary mode when you transferred it?)", "");
  9693. X      return ZE_FORM;
  9694. X    }
  9695. X    if (fread(b, ENDHEAD, 1, f) != 1)
  9696. X      return ferror(f) ? ZE_READ : ZE_EOF;
  9697. X    if (SH(ENDDSK + b) || SH(ENDBEG + b) ||
  9698. X        SH(ENDSUB + b) != SH(ENDTOT + b))
  9699. X      warn("multiple disk information ignored", "");
  9700. X    if (zcount != SH(ENDSUB + b))
  9701. X    {
  9702. X      warn("count in end of central directory incorrect", "");
  9703. X      return ZE_FORM;
  9704. X    }
  9705. X    if (LG(ENDSIZ + b) != p - s)
  9706. X    {
  9707. X      warn("central directory size is incorrect (made by stzip?)", "");
  9708. X      /* stzip 0.9 gets this wrong, so be tolerant */
  9709. X      /* return ZE_FORM; */
  9710. X    }
  9711. X    if (LG(ENDOFF + b) != s)
  9712. X    {
  9713. X      warn("central directory start is incorrect", "");
  9714. X      return ZE_FORM;
  9715. X    }
  9716. X    cenbeg = s;
  9717. X    zcomlen = SH(ENDCOM + b);
  9718. X    if (zcomlen)
  9719. X    {
  9720. X      if ((zcomment = malloc(zcomlen)) == NULL)
  9721. X        return ZE_MEM;
  9722. X      if (fread(zcomment, zcomlen, 1, f) != 1)
  9723. X      {
  9724. X        free((voidp *)zcomment);
  9725. X        return ferror(f) ? ZE_READ : ZE_EOF;
  9726. X      }
  9727. X    }
  9728. X    if (zipbeg)
  9729. X    {
  9730. X      sprintf(errbuf, " has a preamble of %ld bytes", zipbeg);
  9731. X      warn(zipfile, errbuf);
  9732. X    }
  9733. X    if (getc(f) != EOF)
  9734. X      warn("garbage at end of zip file ignored", "");
  9735. X
  9736. X    /* Done with zip file for now */
  9737. X    fclose(f);
  9738. X    
  9739. X    /* If one or more files, sort by name */
  9740. X    if (zcount)
  9741. X    {
  9742. X      if ((x = zsort =
  9743. X          (struct zlist far **)malloc(zcount * sizeof(struct zlist far *))) ==
  9744. X          NULL)
  9745. X        return ZE_MEM;
  9746. X      for (z = zfiles; z != NULL; z = z->nxt)
  9747. X        *x++ = z;
  9748. X      qsort((char *)zsort, zcount, sizeof(struct zlist far *), zqcmp);
  9749. X    }
  9750. X  }
  9751. X  return ZE_OK;
  9752. X}
  9753. X
  9754. X
  9755. Xint putlocal(z, f)
  9756. Xstruct zlist far *z;    /* zip entry to write local header for */
  9757. XFILE *f;                /* file to write to */
  9758. X/* Write a local header described by *z to file *f.  Return an error code
  9759. X   in the ZE_ class. */
  9760. X{
  9761. X  PUTLG(LOCSIG, f);
  9762. X  PUTSH(z->ver, f);
  9763. X  PUTSH(z->lflg, f);
  9764. X  PUTSH(z->how, f);
  9765. X  PUTLG(z->tim, f);
  9766. X  PUTLG(z->crc, f);
  9767. X  PUTLG(z->siz, f);
  9768. X  PUTLG(z->len, f);
  9769. X  PUTSH(z->nam, f);
  9770. X  PUTSH(z->ext, f);
  9771. X  if (fwrite(z->zname, 1, z->nam, f) != z->nam ||
  9772. X      (z->ext && fwrite(z->extra, 1, z->ext, f) != z->ext))
  9773. X    return ZE_TEMP;
  9774. X  return ZE_OK;
  9775. X}
  9776. X
  9777. Xint putextended(z, f)
  9778. Xstruct zlist far *z;    /* zip entry to write local header for */
  9779. XFILE *f;                /* file to write to */
  9780. X/* Write an extended local header described by *z to file *f.
  9781. X * Return an error code in the ZE_ class. */
  9782. X{
  9783. X  PUTLG(EXTLOCSIG, f);
  9784. X  PUTLG(z->crc, f);
  9785. X  PUTLG(z->siz, f);
  9786. X  PUTLG(z->len, f);
  9787. X  return ZE_OK;
  9788. X}
  9789. X
  9790. Xint putcentral(z, f)
  9791. Xstruct zlist far *z;    /* zip entry to write central header for */
  9792. XFILE *f;                /* file to write to */
  9793. X/* Write a central header described by *z to file *f.  Return an error code
  9794. X   in the ZE_ class. */
  9795. X{
  9796. X  PUTLG(CENSIG, f);
  9797. X  PUTSH(z->vem, f);
  9798. X  PUTSH(z->ver, f);
  9799. X  PUTSH(z->flg, f);
  9800. X  PUTSH(z->how, f);
  9801. X  PUTLG(z->tim, f);
  9802. X  PUTLG(z->crc, f);
  9803. X  PUTLG(z->siz, f);
  9804. X  PUTLG(z->len, f);
  9805. X  PUTSH(z->nam, f);
  9806. X  PUTSH(z->cext, f);
  9807. X  PUTSH(z->com, f);
  9808. X  PUTSH(z->dsk, f);
  9809. X  PUTSH(z->att, f);
  9810. X  PUTLG(z->atx, f);
  9811. X  PUTLG(z->off, f);
  9812. X  if (fwrite(z->zname, 1, z->nam, f) != z->nam ||
  9813. X      (z->cext && fwrite(z->cextra, 1, z->cext, f) != z->cext) ||
  9814. X      (z->com && fwrite(z->comment, 1, z->com, f) != z->com))
  9815. X    return ZE_TEMP;
  9816. X  return ZE_OK;
  9817. X}
  9818. X
  9819. X
  9820. Xint putend(n, s, c, m, z, f)
  9821. Xint n;                  /* number of entries in central directory */
  9822. Xulg s, c;               /* size and offset of central directory */
  9823. Xextent m;               /* length of zip file comment (0 if none) */
  9824. Xchar *z;                /* zip file comment if m != 0 */
  9825. XFILE *f;                /* file to write to */
  9826. X/* Write the end of central directory data to file *f.  Return an error code
  9827. X   in the ZE_ class. */
  9828. X{
  9829. X  PUTLG(ENDSIG, f);
  9830. X  PUTSH(0, f);
  9831. X  PUTSH(0, f);
  9832. X  PUTSH(n, f);
  9833. X  PUTSH(n, f);
  9834. X  PUTLG(s, f);
  9835. X  PUTLG(c, f);
  9836. X  PUTSH(m, f);
  9837. X  if (m && fwrite(z, 1, m, f) != m)
  9838. X    return ZE_TEMP;
  9839. X  return ZE_OK;
  9840. X}
  9841. X
  9842. X
  9843. X#ifndef UTIL
  9844. X
  9845. Xlocal char *cutpath(p)
  9846. Xchar *p;                /* path string */
  9847. X/* Cut the last path component off the name *p in place.  Return p. */
  9848. X{
  9849. X  char *r;              /* pointer to last path delimiter */
  9850. X
  9851. X#ifdef VMS                      /* change [w.x.y]z to [w.x]y.DIR */
  9852. X  if ((r = strrchr(p, ']')) != NULL)
  9853. X  {
  9854. X    *r = 0;
  9855. X    if ((r = strrchr(p, '.')) != NULL)
  9856. X    {
  9857. X      *r = ']';
  9858. X      strcat(r, ".DIR");        /* this assumes a little padding--see PAD */
  9859. X    }
  9860. X    else
  9861. X      *p = 0;
  9862. X  }
  9863. X  else
  9864. X    *p = 0;
  9865. X#else /* !VMS */                /* change w/x/y/z to w/x/y */
  9866. X  if ((r = strrchr(p, '/')) != NULL)
  9867. X    *r = 0;
  9868. X  else
  9869. X    *p = 0;
  9870. X#endif /* ?VMS */
  9871. X  return p;
  9872. X}
  9873. X
  9874. X
  9875. Xint trash()
  9876. X/* Delete the compressed files and the directories that contained the deleted
  9877. X   files, if empty.  Return an error code in the ZE_ class.  Failure of
  9878. X   destroy() or deletedir() is ignored. */
  9879. X{
  9880. X  extent i;             /* counter on deleted names */
  9881. X  extent k;             /* number of deleted directories this pass */
  9882. X  extent n;             /* number of deleted names left to handle */
  9883. X  struct zlist far **s; /* table of zip entries to handle, sorted */
  9884. X  struct zlist far *z;  /* current zip entry */
  9885. X
  9886. X  /* Count and delete marked names */
  9887. X  n = 0;
  9888. X  for (z = zfiles; z != NULL; z = z->nxt)
  9889. X    if (z->mark || z->trash)
  9890. X    {
  9891. X      z->mark = 1;
  9892. X      n++;
  9893. X      if (verbose)
  9894. X        printf("zip diagnostic: trashing file %s\n", z->name);
  9895. X      destroy(z->name);
  9896. X    }
  9897. X
  9898. X  /* Try to delete all paths that lead up to marked names */
  9899. X  if (n)
  9900. X  {
  9901. X    if ((s = (struct zlist far **)malloc((n+1)*sizeof(struct zlist far *))) ==
  9902. X        NULL ||
  9903. X        (s[0] = (struct zlist far *)farmalloc(sizeof(struct zlist))) == NULL)
  9904. X      return ZE_MEM;
  9905. X    s[0]->name = "";
  9906. X    s++;
  9907. X    do {
  9908. X      n = k = 0;
  9909. X      for (z = zfiles; z != NULL; z = z->nxt)
  9910. X        if (z->mark)
  9911. X          s[n++] = z;
  9912. X      qsort((char *)s, n, sizeof(struct zlist far *), zqcmp);
  9913. X      for (i = 0; i < n; i++)
  9914. X        if (*cutpath(s[i]->name) && strcmp(s[i]->name, s[i-1]->name))
  9915. X        {
  9916. X          if (verbose)
  9917. X            printf("zip diagnostic: trashing directory %s\n", s[i]->name);
  9918. X          deletedir(s[i]->name);
  9919. X          k++;
  9920. X        }
  9921. X        else
  9922. X          s[i]->mark = 0;
  9923. X    } while (k);
  9924. X    farfree((voidp far *)((--s)[0]));
  9925. X    free((voidp *)s);
  9926. X  }
  9927. X  return ZE_OK;
  9928. X}
  9929. X
  9930. X#endif /* !UTIL */
  9931. END_OF_FILE
  9932.   if test 24578 -ne `wc -c <'zipfile.c'`; then
  9933.     echo shar: \"'zipfile.c'\" unpacked with wrong size!
  9934.   fi
  9935.   # end of 'zipfile.c'
  9936. fi
  9937. echo shar: End of archive 6 \(of 11\).
  9938. cp /dev/null ark6isdone
  9939. MISSING=""
  9940. for I in 1 2 3 4 5 6 7 8 9 10 11 ; do
  9941.     if test ! -f ark${I}isdone ; then
  9942.     MISSING="${MISSING} ${I}"
  9943.     fi
  9944. done
  9945. if test "${MISSING}" = "" ; then
  9946.     echo You have unpacked all 11 archives.
  9947.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  9948. else
  9949.     echo You still must unpack the following archives:
  9950.     echo "        " ${MISSING}
  9951. fi
  9952. exit 0
  9953. exit 0 # Just in case...
  9954. Newsgroups: comp.sources.misc
  9955. From: zip-bugs@cs.ucla.edu (Info-ZIP group)
  9956. Subject:  v31i099:  zip19 - Info-ZIP portable Zip, version 1.9, Part07/11
  9957. Message-ID: <1992Aug23.064739.29343@sparky.imd.sterling.com>
  9958. X-Md4-Signature: 78834c85a8bc38b5c3e178b5fc3ec576
  9959. Date: Sun, 23 Aug 1992 06:47:39 GMT
  9960. Approved: kent@sparky.imd.sterling.com
  9961.  
  9962. Submitted-by: zip-bugs@cs.ucla.edu (Info-ZIP group)
  9963. Posting-number: Volume 31, Issue 99
  9964. Archive-name: zip19/part07
  9965. Supersedes: zip: Volume 23, Issue 88-96
  9966. Environment: UNIX, VMS, OS/2, MS-DOS, MACINTOSH, WIN-NT, LINUX, MINIX, XOS, !AMIGA, ATARI, symlink, SGI, DEC, Cray, Convex, Amdahl, Sun, PC
  9967.  
  9968. #! /bin/sh
  9969. # This is a shell archive.  Remove anything before this line, then feed it
  9970. # into a shell via "sh file" or similar.  To overwrite existing files,
  9971. # type "sh file -c".
  9972. # The tool that generated this appeared in the comp.sources.unix newsgroup;
  9973. # send mail to comp-sources-unix@uunet.uu.net if you want that tool.
  9974. # Contents:  msdos/makefile.gcc.UU vms/vms.c vms/vms_zip.rnh zipsplit.c
  9975. # Wrapped by kent@sparky on Sun Aug 23 01:00:45 1992
  9976. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  9977. echo If this archive is complete, you will see the following message:
  9978. echo '          "shar: End of archive 7 (of 11)."'
  9979. if test -f 'msdos/makefile.gcc.UU' -a "${1}" != "-c" ; then 
  9980.   echo shar: Will not clobber existing file \"'msdos/makefile.gcc.UU'\"
  9981. else
  9982.   echo shar: Extracting \"'msdos/makefile.gcc.UU'\" \(2879 characters\)
  9983.   sed "s/^X//" >'msdos/makefile.gcc.UU' <<'END_OF_FILE'
  9984. Xbegin 666 msdos/makefile.gcc
  9985. XM(R!-86ME9FEL92!F;W(@6FEP+"!::7!#;&]A:RP@6FEP3F]T92!A;F0@6FEP
  9986. XM4W!L:70@9F]R#0HC(&1J9V-C(#$N,#8-"@T*0U)94%1//0T*0TQ/04L]#0I#
  9987. XM4D9,04<]#0H-"B,@("HJ*B!&;W(@96YC<GEP=&EO;B!V97)S:6]N+"!R96UO
  9988. XM=F4@=&AE(",@870@=&AE(&9R;VYT(&]F(&YE>'0@,R!L:6YE<R J*BH-"B-#
  9989. XM4EE05$\]8W)Y<'0N;PT*(T-,3T%+/7II<&-L;V%K+F5X90T*(T-21DQ!1STM
  9990. XM1$-265!4#0H-"B,@+2TM+2TM+2TM+2TM+2!D:F=C8R M+2TM+2TM+2TM+2TM
  9991. XM#0I#1DQ!1U,]+5=A;&P@+4\R("U$3D]?05--("0H0U)&3$%'*0T*551)3$9,
  9992. XM04=3/2U$551)3" D*$-&3$%'4RD@+6\-"D-#/6=C8PT*3$0]9V-C#0I,1$9,
  9993. XM04=3/2US#0H-"B,@=F%R:6%B;&5S#0I/0DI:(#T@>FEP+F\@>FEP9FEL92YO
  9994. XM('II<'5P+F\@9FEL96EO+F\@=71I;"YO(&=L;V)A;',N;R D*$-265!43RD-
  9995. XM"@T*3T)*52 ]('II<&9I;&5?+F\@>FEP=7!?+F\@9FEL96EO7RYO('5T:6Q?
  9996. XM+F\@9VQO8F%L<RYO#0I/0DI.(#T@>FEP;F]T92YO(" D*$]"2E4I#0I/0DI#
  9997. XM(#T@>FEP8VQO86LN;R D*$]"2E4I(&-R>7!T7RYO#0I/0DI3(#T@>FEP<W!L
  9998. XM:70N;R D*$]"2E4I#0H-"GII<',Z"7II<"!Z:7!N;W1E('II<'-P;&ET("0H
  9999. XM0TQ/04LI#0H-"GII<"YO.@D@(" @("!Z:7 N:"!Z:7!E<G(N:"!T86EL;W(N
  10000. XM:"!R979I<VEO;BYH('II<"YC#0H-"GII<&9I;&4N;SH@(" @>FEP+F@@>FEP
  10001. XM97)R+F@@=&%I;&]R+F@@>FEP9FEL92YC#0H-"GII<'5P+F\Z(" @(" @>FEP
  10002. XM+F@@>FEP97)R+F@@=&%I;&]R+F@@<F5V:7-I;VXN:"!Z:7!U<"YC#0H-"F9I
  10003. XM;&5I;RYO.B @(" @>FEP+F@@>FEP97)R+F@@=&%I;&]R+F@@9FEL96EO+F,-
  10004. XM"@T*=71I;"YO.B @(" @("!Z:7 N:"!Z:7!E<G(N:"!T86EL;W(N:"!U=&EL
  10005. XM+F,-"@T*9VQO8F%L<RYO.B @("!Z:7 N:"!Z:7!E<G(N:"!T86EL;W(N:"!G
  10006. XM;&]B86QS+F,-"@T*9&5F;&%T92YO.B @("!Z:7 N:"!Z:7!E<G(N:"!T86EL
  10007. XM;W(N:"!D969L871E+F,-"@T*=')E97,N;SH@(" @("!Z:7 N:"!Z:7!E<G(N
  10008. XM:"!T86EL;W(N:"!T<F5E<RYC#0H-"F)I=',N;SH@(" @(" @>FEP+F@@>FEP
  10009. XM97)R+F@@=&%I;&]R+F@@8FET<RYC#0H-"F-R>7!T+F\Z(" @(" @>FEP+F@@
  10010. XM>FEP97)R+F@@=&%I;&]R+F@@8W)Y<'0N8PT*#0IZ:7!C;&]A:RYO.B @('II
  10011. XM<"YH('II<&5R<BYH('1A:6QO<BYH(')E=FES:6]N+F@@>FEP8VQO86LN8PT*
  10012. XM#0IZ:7!N;W1E+F\Z(" @('II<"YH('II<&5R<BYH('1A:6QO<BYH(')E=FES
  10013. XM:6]N+F@@>FEP;F]T92YC#0H-"GII<'-P;&ET+F\Z(" @>FEP<W!L:70N8R!Z
  10014. XM:7 N:"!Z:7!E<G(N:"!T86EL;W(N:"!R979I<VEO;BYH#0H-"GII<&9I;&5?
  10015. XM+F\Z(" @>FEP9FEL92YC('II<"YH('II<&5R<BYH('1A:6QO<BYH#0H))"A#
  10016. XM0RD@+6,@)"A55$E,1DQ!1U,I("1 ('II<&9I;&4N8PT*#0IZ:7!U<%\N;SH@
  10017. XM(" @('II<'5P+F,@>FEP+F@@>FEP97)R+F@@=&%I;&]R+F@-"@DD*$-#*2 M
  10018. XM8R D*%5424Q&3$%'4RD@)$ @>FEP=7 N8PT*#0IF:6QE:6]?+F\Z(" @(&9I
  10019. XM;&5I;RYC('II<"YH('II<&5R<BYH('1A:6QO<BYH#0H))"A#0RD@+6,@)"A5
  10020. XM5$E,1DQ!1U,I("1 (&9I;&5I;RYC#0H-"G5T:6Q?+F\Z(" @('5T:6PN8R!Z
  10021. XM:7 N:"!Z:7!E<G(N:"!T86EL;W(N: T*"20H0T,I("UC("0H551)3$9,04=3
  10022. XM*2 D0"!F:6QE:6\N8PT*#0IC<GEP=%\N;SH@(" @(&-R>7!T+F,@>FEP+F@-
  10023. XM"@DD*$-#*2 M8R D*%5424Q&3$%'4RD@)$ @8W)Y<'0N8PT*#0IZ:7 Z("0H
  10024. XM3T)*6BD@)"A/0DI)*0T*"20H3$0I("0H3$1&3$%'4RD@)"A/0DI:*2 D*$]"
  10025. XM2DDI("UO("1 #0H)86]U=#)E>&4@)$ -"@ED96P@)$ -"@T*>FEP8VQO86LZ
  10026. XM("0H3T)*0RD-"@DD*$Q$*2 D*$Q$1DQ!1U,I("0H3T)*0RD@+6\@)$ -"@EA
  10027. XM;W5T,F5X92 D0 T*"61E;" D0 T*#0IZ:7!N;W1E.B D*$]"2DXI#0H))"A,
  10028. XM1"D@)"A,1$9,04=3*2 D*$]"2DXI("UO("1 #0H)86]U=#)E>&4@)$ -"@ED
  10029. XM96P@)$ -"@T*>FEP<W!L:70Z("0H3T)*4RD-"@DD*$Q$*2 D*$Q$1D%'4RD@
  10030. XF)"A/0DI3*2 M;R D0 T*"6%O=70R97AE("1 #0H)9&5L("1 #0I$
  10031. Xend
  10032. END_OF_FILE
  10033.   if test 2879 -ne `wc -c <'msdos/makefile.gcc.UU'`; then
  10034.     echo shar: \"'msdos/makefile.gcc.UU'\" unpacked with wrong size!
  10035.   else
  10036.     echo shar: Uudecoding \"'msdos/makefile.gcc'\" \(2063 characters\)
  10037.     cat msdos/makefile.gcc.UU | uudecode
  10038.     if test 2063 -ne `wc -c <'msdos/makefile.gcc'`; then
  10039.       echo shar: \"'msdos/makefile.gcc'\" uudecoded with wrong size!
  10040.     else
  10041.       rm msdos/makefile.gcc.UU
  10042.     fi
  10043.   fi
  10044.   # end of 'msdos/makefile.gcc.UU'
  10045. fi
  10046. if test -f 'vms/vms.c' -a "${1}" != "-c" ; then 
  10047.   echo shar: Will not clobber existing file \"'vms/vms.c'\"
  10048. else
  10049.   echo shar: Extracting \"'vms/vms.c'\" \(18616 characters\)
  10050.   sed "s/^X//" >'vms/vms.c' <<'END_OF_FILE'
  10051. X/*************************************************************************
  10052. X *                                                                       *
  10053. X * VMS portions copyright (C) 1992 Igor Mandrichenko.                    *
  10054. X * Permission is granted to any individual or institution to use, copy,  *
  10055. X * or redistribute this software so long as all of the original files    *
  10056. X * are included unmodified, that it is not sold for profit, and that     *
  10057. X * this copyright notice is retained.                                    *
  10058. X *                                                                       *
  10059. X *************************************************************************/
  10060. X
  10061. X/*
  10062. X *  vms.c (zip) by Igor Mandrichenko    Version 2.1-1
  10063. X *
  10064. X *  Revision history:
  10065. X *  ...
  10066. X *  2.1-1       16-feb-1992     I.Mandrichenko  
  10067. X *      Get file size from XABFHC and check bytes rest in file before
  10068. X *      reading. 
  10069. X *  2.1-2       2-mar-1992      I.Mandrichenko
  10070. X *      Make code more standard
  10071. X *  2.2         21-jun-1992     I.Mandrichenko
  10072. X *      Free all allocated space, use more static storage.
  10073. X *      Use memcompress() from bits.c (deflation) for block compression.
  10074. X *      To revert to old compression method #define OLD_COMPRESS
  10075. X */
  10076. X
  10077. X#ifdef VMS                      /* For VMS only ! */
  10078. X
  10079. X#define OLD_COMPRESS    /*To use old compression method define it.*/
  10080. X
  10081. X#include <rms.h>
  10082. X#include <descrip.h>
  10083. X#include <syidef.h>
  10084. X
  10085. X#ifndef VAXC
  10086. X                                /* This definition may be missed */
  10087. Xstruct XAB {
  10088. X    unsigned char xab$b_cod;
  10089. X    unsigned char xab$b_bln;
  10090. X    short int xabdef$$_fill_1;
  10091. X    char *xab$l_nxt;
  10092. X};
  10093. X
  10094. X#endif
  10095. X
  10096. X#ifndef SYI$_VERSION
  10097. X#define SYI$_VERSION 4096       /* VMS 5.4 definition */
  10098. X#endif
  10099. X
  10100. X#include "zip.h"
  10101. X
  10102. X#define ERR(s)  !((s)&1)
  10103. X
  10104. X#define RET_ERROR 1
  10105. X#define RET_SUCCESS 0
  10106. X#define RET_EOF 0
  10107. X
  10108. X#define Kbyte 1024
  10109. X
  10110. Xtypedef struct XAB *xabptr;
  10111. X
  10112. X/*
  10113. X*   Extra record format
  10114. X*   ===================
  10115. X*   signature       (2 bytes)   = 'I','M'
  10116. X*   size            (2 bytes)
  10117. X*   block signature (4 bytes)
  10118. X*   flags           (2 butes)
  10119. X*   uncomprssed size(2 bytes)
  10120. X*   reserved        (4 bytes)
  10121. X*   data            (size-12 bytes)
  10122. X*   ....
  10123. X*/
  10124. X
  10125. X
  10126. X/*
  10127. X*   Extra field signature and block signatures
  10128. X*/
  10129. X#define SIGNATURE "IM"
  10130. X#define EXTBSL  4               /* Block signature length   */
  10131. X#define RESL    8
  10132. X
  10133. X#define BC_MASK         07      /* 3 bits for compression type */       
  10134. X#define BC_STORED       0       /* Stored */
  10135. X#define BC_00           1       /* 0byte -> 0bit compression */
  10136. X#define BC_DEFL         2       /* Deflated */
  10137. X
  10138. Xstruct extra_block
  10139. X{       ush     im_sig;
  10140. X        ush     size;
  10141. X        ulg     block_sig;
  10142. X        ush     flags;
  10143. X        ush     length;
  10144. X        ulg     reserved;
  10145. X        uch     body[1];        /* The actual size is unknown */
  10146. X};
  10147. X
  10148. X#define FABSIG  "VFAB"
  10149. X#define XALLSIG "VALL"
  10150. X#define XFHCSIG "VFHC"
  10151. X#define XDATSIG "VDAT"
  10152. X#define XRDTSIG "VRDT"
  10153. X#define XPROSIG "VPRO"
  10154. X#define XKEYSIG "VKEY"
  10155. X#define VERSIG  "VMSV"
  10156. X/*
  10157. X*   Block sizes
  10158. X*/
  10159. X#define FABL    (cc$rms_fab.fab$b_bln)
  10160. X#define RABL    (cc$rms_rab.rab$b_bln)
  10161. X#define XALLL   (cc$rms_xaball.xab$b_bln)
  10162. X#define XDATL   (cc$rms_xabdat.xab$b_bln)
  10163. X#define XFHCL   (cc$rms_xabfhc.xab$b_bln)
  10164. X#define XKEYL   (cc$rms_xabkey.xab$b_bln)
  10165. X#define XPROL   (cc$rms_xabpro.xab$b_bln)
  10166. X#define XRDTL   (cc$rms_xabrdt.xab$b_bln)
  10167. X#define XSUML   (cc$rms_xabsum.xab$b_bln)
  10168. X#define EXTHL   (4+EXTBSL+RESL)
  10169. X#define EXTL0   ((FABL + EXTHL)+        \
  10170. X                (XFHCL + EXTHL)+        \
  10171. X                (XPROL + EXTHL)+        \
  10172. X                (XDATL + EXTHL)+        \
  10173. X                (XRDTL + EXTHL))
  10174. X
  10175. X#ifdef OLD_COMPRESS
  10176. X#define PAD     sizeof(uch)
  10177. X#else
  10178. X#define PAD     10*sizeof(ush)          /* Two extra bytes for compr. header */
  10179. X#endif
  10180. X
  10181. X#define PAD0    (5*PAD)                 /* Reserve space for the case when
  10182. X                                        *  compression failes */
  10183. Xstatic int _compress();
  10184. X
  10185. X/***********************************
  10186. X *   Function get_vms_attributes   *
  10187. X ***********************************/
  10188. X
  10189. Xstatic uch *_compress_block();
  10190. Xstatic int get_vms_version();
  10191. X
  10192. Xint get_vms_attributes(z)
  10193. X  struct zlist *z;
  10194. X/*
  10195. X *      Get file VMS file attributes and store them into extent fields.
  10196. X *      Store VMS version also.
  10197. X *      On error leave z intact.
  10198. X */
  10199. X{
  10200. X    int status;
  10201. X    uch *extra=(uch*)NULL, *scan;
  10202. X    extent extra_l;
  10203. X    static struct FAB fab;
  10204. X    static struct XABSUM xabsum;
  10205. X    static struct XABFHC xabfhc;
  10206. X    static struct XABDAT xabdat;
  10207. X    static struct XABPRO xabpro;
  10208. X    static struct XABRDT xabrdt;
  10209. X    xabptr x = (xabptr)NULL, xab_chain = (xabptr)NULL, last_xab = (xabptr)NULL;
  10210. X    int nk, na;
  10211. X    int i;
  10212. X    int rc=RET_ERROR;
  10213. X    char verbuf[80];
  10214. X    int verlen = 0;
  10215. X
  10216. X    /*
  10217. X    *   Initialize RMS control blocks and link them
  10218. X    */
  10219. X
  10220. X    fab =    cc$rms_fab;
  10221. X    xabsum = cc$rms_xabsum;
  10222. X    xabdat = cc$rms_xabdat;
  10223. X    xabfhc = cc$rms_xabfhc;
  10224. X    xabpro = cc$rms_xabpro;
  10225. X    xabrdt = cc$rms_xabrdt;
  10226. X
  10227. X
  10228. X    fab.fab$l_xab = (char*)&xabsum;
  10229. X    /*
  10230. X    *   Open the file and read summary information.
  10231. X    */
  10232. X    fab.fab$b_fns = strlen(z->name);
  10233. X    fab.fab$l_fna = z->name;
  10234. X
  10235. X    status = sys$open(&fab);
  10236. X    if (ERR(status))
  10237. X    {
  10238. X#ifdef DEBUG
  10239. X        printf("get_vms_attributes: sys$open for file %s:\n  error status = %d\n",
  10240. X               z->name, status);
  10241. X#endif
  10242. X        goto err_exit;
  10243. X    }
  10244. X
  10245. X    nk = xabsum.xab$b_nok;
  10246. X    na = xabsum.xab$b_noa;
  10247. X#ifdef DEBUG
  10248. X    printf("%d keys, %d alls\n", nk, na);
  10249. X#endif
  10250. X
  10251. X    /*
  10252. X    *   Allocate XABKEY and XABALL blocks ind link them
  10253. X    */
  10254. X
  10255. X    xabfhc.xab$l_nxt = (char*)&xabdat;
  10256. X    xabdat.xab$l_nxt = (char*)&xabpro;
  10257. X    xabpro.xab$l_nxt = (char*)&xabrdt;
  10258. X    xabrdt.xab$l_nxt = (char*)0L;
  10259. X
  10260. X    xab_chain = (xabptr)(&xabfhc);
  10261. X    last_xab  = (xabptr)(&xabrdt);
  10262. X
  10263. X#define INIT(ptr,size,init)     \
  10264. X        if( (ptr = (uch*)malloc(size)) == NULL )        \
  10265. X        {                                               \
  10266. X              printf( "get_vms_attributes: Insufficient memory.\n" );   \
  10267. X                      goto err_exit;                    \
  10268. X        }                                               \
  10269. X        *(ptr) = (init);
  10270. X    /*
  10271. X    *   Allocate and initialize all needed XABKEYs and XABALLs
  10272. X    */
  10273. X    for (i = 0; i < nk; i++)
  10274. X    {
  10275. X        struct XABKEY *k;
  10276. X        INIT(k, XKEYL, cc$rms_xabkey);
  10277. X        k->xab$b_ref = i;
  10278. X        if (last_xab != 0L)
  10279. X            last_xab->xab$l_nxt = (char*)k;
  10280. X        last_xab = (xabptr)k;
  10281. X    }
  10282. X    for (i = 0; i < na; i++)
  10283. X    {
  10284. X        struct XABALL *a;
  10285. X        INIT(a, XALLL, cc$rms_xaball);
  10286. X        a->xab$b_aid = i;
  10287. X        if (last_xab != 0L)
  10288. X            last_xab->xab$l_nxt = (char*)a;
  10289. X        last_xab = (xabptr)a;
  10290. X    }
  10291. X
  10292. X    fab.fab$l_xab = (char*)xab_chain;
  10293. X#ifdef DEBUG
  10294. X    printf("Dump of XAB chain before DISPLAY:\n");
  10295. X    for (x = xab_chain; x != 0L; x = x->xab$l_nxt)
  10296. X        dump_rms_block(x);
  10297. X#endif
  10298. X    /*
  10299. X    *   Get information on the file structure etc.
  10300. X    */
  10301. X    status = sys$display(&fab, 0, 0);
  10302. X    if (ERR(status))
  10303. X    {
  10304. X#ifdef DEBUG
  10305. X        printf("get_vms_attributes: sys$display for file %s:\n  error status = %d\n",
  10306. X               z->name, status);
  10307. X#endif
  10308. X        goto err_exit;
  10309. X    }
  10310. X
  10311. X#ifdef DEBUG
  10312. X    printf("\nDump of XAB chain after DISPLAY:\n");
  10313. X    for (x = xab_chain; x != 0L; x = x->xab$l_nxt)
  10314. X        dump_rms_block(x);
  10315. X#endif
  10316. X
  10317. X    fab.fab$l_xab = 0;  /* Keep XABs */
  10318. X    status = sys$close(&fab);
  10319. X    if (ERR(status))
  10320. X    {
  10321. X#ifdef DEBUG
  10322. X        printf("get_vms_attributes: sys$close for file %s:\n  error status = %d\n",
  10323. X               z->name, status);
  10324. X#endif
  10325. X        goto err_exit;
  10326. X    }
  10327. X
  10328. X    extra_l = EXTL0 + nk * (XKEYL + EXTHL) + na * (XALLL + EXTHL);
  10329. X#ifndef OLD_COMPRESS
  10330. X    extra_l += PAD0 + (nk+na) * PAD;
  10331. X#endif
  10332. X
  10333. X    if( verlen = get_vms_version(verbuf,sizeof(verbuf)) )
  10334. X    {   extra_l += verlen + EXTHL;
  10335. X#ifndef OLD_COMPRESS
  10336. X        extra_l += PAD;
  10337. X#endif
  10338. X    }
  10339. X
  10340. X    if ((scan = extra = (uch *) malloc(extra_l)) == (uch*)NULL)
  10341. X    {
  10342. X#ifdef DEBUG
  10343. X        printf("get_vms_attributes: Insufficient memory to allocate extra buffer\n");
  10344. X#endif
  10345. X        goto err_exit;
  10346. X    }
  10347. X
  10348. X
  10349. X    if( verlen > 0 )
  10350. X        scan = _compress_block(scan,verbuf, verlen, VERSIG);
  10351. X
  10352. X    /*
  10353. X     *  Zero all unusable fields to improve compression
  10354. X     */
  10355. X    fab.fab$b_fns = fab.fab$b_shr = fab.fab$b_dns = fab.fab$b_fac = 0;
  10356. X    fab.fab$w_ifi = 0;
  10357. X    fab.fab$l_stv = fab.fab$l_sts = fab.fab$l_ctx = 0;
  10358. X    fab.fab$l_fna = fab.fab$l_nam = fab.fab$l_xab = fab.fab$l_dna = (char*)0L;
  10359. X
  10360. X#ifdef DEBUG
  10361. X    dump_rms_block( &fab );
  10362. X#endif
  10363. X    scan = _compress_block(scan,&fab, FABL, FABSIG);
  10364. X    for (x = xab_chain; x != 0L;)
  10365. X    {
  10366. X        int bln;
  10367. X        char *sig;
  10368. X        xabptr next;
  10369. X
  10370. X        next = (xabptr)(x->xab$l_nxt);
  10371. X        x->xab$l_nxt = 0;
  10372. X
  10373. X        switch (x->xab$b_cod)
  10374. X        {
  10375. X            case XAB$C_ALL:
  10376. X                bln = XALLL;
  10377. X                sig = XALLSIG;
  10378. X                break;
  10379. X            case XAB$C_KEY:
  10380. X                bln = XKEYL;
  10381. X                sig = XKEYSIG;
  10382. X                break;
  10383. X            case XAB$C_PRO:
  10384. X                bln = XPROL;
  10385. X                sig = XPROSIG;
  10386. X                break;
  10387. X            case XAB$C_FHC:
  10388. X                bln = XFHCL;
  10389. X                sig = XFHCSIG;
  10390. X                break;
  10391. X            case XAB$C_DAT:
  10392. X                bln = XDATL;
  10393. X                sig = XDATSIG;
  10394. X                break;
  10395. X            case XAB$C_RDT:
  10396. X                bln = XRDTL;
  10397. X                sig = XRDTSIG;
  10398. X                break;
  10399. X            default:
  10400. X                bln = 0;
  10401. X                sig = 0L;
  10402. X                break;
  10403. X        }
  10404. X        if (bln > 0)
  10405. X            scan = _compress_block(scan,x, bln, sig);
  10406. X        x = next;
  10407. X    }
  10408. X
  10409. X    z->ext = z->cext = scan-extra;
  10410. X    z->extra = z->cextra = (char*)extra;
  10411. X    rc = RET_SUCCESS;
  10412. X
  10413. Xerr_exit:
  10414. X    /*
  10415. X    * Give up all allocated blocks
  10416. X    */
  10417. X    for(x = (struct XAB *)xab_chain; x != 0L; )
  10418. X    {   struct XAB *next;
  10419. X        next = (xabptr)(x->xab$l_nxt);
  10420. X        if( x->xab$b_cod == XAB$C_ALL || x->xab$b_cod == XAB$C_KEY )
  10421. X                free(x);
  10422. X        x = next;
  10423. X    }
  10424. X    return rc;
  10425. X}
  10426. X
  10427. Xstatic int get_vms_version(verbuf,len)
  10428. Xchar *verbuf;
  10429. Xint len;
  10430. X{   int i = SYI$_VERSION;
  10431. X    int verlen = 0;
  10432. X    struct dsc$descriptor version;
  10433. X    char *m;
  10434. X
  10435. X    version.dsc$a_pointer = verbuf;
  10436. X    version.dsc$w_length  = len-1;
  10437. X    version.dsc$b_dtype   = DSC$K_DTYPE_B;
  10438. X    version.dsc$b_class   = DSC$K_CLASS_S;
  10439. X
  10440. X    if (ERR(lib$getsyi(&i, 0, &version, &verlen, 0, 0)) || verlen == 0)
  10441. X        return 0;
  10442. X
  10443. X    /* Cut out trailing spaces "V5.4-3   " -> "V5.4-3" */
  10444. X    for(m=verbuf+verlen,i=verlen-1; i>0 && verbuf[i]==' '; --i) 
  10445. X        --m;
  10446. X    *m = 0;
  10447. X
  10448. X    /* Cut out release number "V5.4-3" -> "V5.4" */
  10449. X    if( (m=strrchr(verbuf,'-')) != (char*)NULL )
  10450. X        *m = 0;
  10451. X    return strlen(verbuf)+1;    /* Transmit ending 0 too */
  10452. X}
  10453. X
  10454. X#define CTXSIG ((ulg)('CtXx'))
  10455. X
  10456. Xtypedef struct user_context
  10457. X{
  10458. X    ulg sig;
  10459. X    struct FAB *fab;
  10460. X    struct RAB *rab;
  10461. X    ulg size,rest;
  10462. X    int status;
  10463. X} Ctx, *Ctxptr;
  10464. X
  10465. XCtx init_ctx =  
  10466. X{       CTXSIG,
  10467. X        0L,
  10468. X        0L,
  10469. X        0L,
  10470. X        0L,
  10471. X        0
  10472. X};
  10473. X
  10474. X#define CTXL    sizeof(Ctx)
  10475. X#define CHECK_RAB(_r) ( (_r) != 0 &&                            \
  10476. X                        (_r) -> rab$b_bid == RAB$C_BID &&       \
  10477. X                        (_r) -> rab$b_bln == RAB$C_BLN &&       \
  10478. X                        (_r) -> rab$l_ctx != 0L     &&          \
  10479. X                        (_r) -> rab$l_fab != 0L )
  10480. X
  10481. X/**************************
  10482. X *   Function vms_open    *
  10483. X **************************/
  10484. Xstruct RAB *vms_open(name)
  10485. X    char *name;
  10486. X{
  10487. X    struct RAB *rab;
  10488. X    struct FAB *fab;
  10489. X    struct XABFHC *fhc;
  10490. X    Ctxptr ctx;
  10491. X
  10492. X    if ((fab = (struct FAB *) malloc(FABL)) == (struct FAB *)NULL)
  10493. X        return 0;
  10494. X    if ((rab = (struct RAB *) malloc(RABL)) == (struct RAB *)NULL)
  10495. X    {
  10496. X        free(fab);
  10497. X        return 0;
  10498. X    }
  10499. X    if ((fhc = (struct XABFHC *) malloc(XFHCL)) == (struct XABFHC *)NULL)
  10500. X    {
  10501. X        free(rab);
  10502. X        free(fab);
  10503. X        return 0;
  10504. X    }
  10505. X    if ((ctx = (Ctxptr) malloc(CTXL)) == (Ctxptr)NULL)
  10506. X    {
  10507. X        free(fhc);
  10508. X        free(fab);
  10509. X        free(rab);
  10510. X        return 0;
  10511. X    }
  10512. X    *fab = cc$rms_fab;
  10513. X    *rab = cc$rms_rab;
  10514. X    *fhc = cc$rms_xabfhc;
  10515. X
  10516. X    fab->fab$l_fna = name;
  10517. X    fab->fab$b_fns = strlen(name);
  10518. X    fab->fab$b_fac = FAB$M_GET | FAB$M_BIO;
  10519. X    fab->fab$l_xab = (char*)fhc;
  10520. X
  10521. X    if (ERR(sys$open(fab)))
  10522. X    {
  10523. X        sys$close(fab);
  10524. X        free(fhc);
  10525. X        free(fab);
  10526. X        free(rab);
  10527. X        free(ctx);
  10528. X        return 0;
  10529. X    }
  10530. X
  10531. X    rab->rab$l_fab = fab;
  10532. X    rab->rab$l_rop = RAB$M_BIO;
  10533. X
  10534. X    if (ERR(sys$connect(rab)))
  10535. X    {
  10536. X        sys$close(fab);
  10537. X        free(fab);
  10538. X        free(rab);
  10539. X        free(ctx);
  10540. X        return 0;
  10541. X    }
  10542. X
  10543. X    *ctx = init_ctx;
  10544. X    ctx->rab = rab;
  10545. X    ctx->fab = fab;
  10546. X
  10547. X    if( fhc->xab$l_ebk > 0 )
  10548. X        ctx->size = ctx->rest = ( fhc->xab$l_ebk-1 ) * 512 + fhc->xab$w_ffb;
  10549. X    else
  10550. X        ctx->size = ctx->rest = 0;
  10551. X    free(fhc);
  10552. X    fab -> fab$l_xab = 0;
  10553. X    rab->rab$l_ctx = (long)ctx;
  10554. X    return rab;
  10555. X}
  10556. X
  10557. X/**************************
  10558. X *   Function vms_close   *
  10559. X **************************/
  10560. Xint vms_close(rab)
  10561. X    struct RAB *rab;
  10562. X{
  10563. X    struct FAB *fab;
  10564. X    Ctxptr ctx;
  10565. X
  10566. X    if (!CHECK_RAB(rab))
  10567. X        return RET_ERROR;
  10568. X    fab = (ctx = (Ctxptr)(rab->rab$l_ctx))->fab;
  10569. X    sys$close(fab);
  10570. X
  10571. X    free(fab);
  10572. X    free(rab);
  10573. X    free(ctx);
  10574. X
  10575. X    return RET_SUCCESS;
  10576. X}
  10577. X
  10578. X/**************************
  10579. X *   Function vms_rewind  *
  10580. X **************************/
  10581. Xint vms_rewind(rab)
  10582. X    struct RAB *rab;
  10583. X{
  10584. X    Ctxptr ctx;
  10585. X
  10586. X    int status;
  10587. X    if (!CHECK_RAB(rab))
  10588. X        return RET_ERROR;
  10589. X
  10590. X    ctx = (Ctxptr) (rab->rab$l_ctx);
  10591. X    if (ERR(status = sys$rewind(rab)))
  10592. X    {
  10593. X        ctx->status = status;
  10594. X        return RET_ERROR;
  10595. X    }
  10596. X
  10597. X    ctx->status = 0;
  10598. X    ctx->rest = ctx->size;
  10599. X    
  10600. X    return RET_SUCCESS;
  10601. X}
  10602. X
  10603. X/**************************
  10604. X *   Function vms_read    *
  10605. X **************************/
  10606. Xint vms_read(rab, buf, size)
  10607. X    struct RAB *rab;
  10608. Xchar *buf;
  10609. Xint size;
  10610. X/*
  10611. X*       size must be greater or equal to 512 !
  10612. X*/
  10613. X{
  10614. X    int status;
  10615. X    Ctxptr ctx;
  10616. X
  10617. X    ctx = (Ctxptr)rab->rab$l_ctx;
  10618. X
  10619. X    if (!CHECK_RAB(rab))
  10620. X        return 0;
  10621. X
  10622. X    if (ctx -> rest <= 0)
  10623. X        return 0;               /* Eof */
  10624. X
  10625. X    if(size > 16*Kbyte)         /* RMS can not read too much */
  10626. X        size = 16*Kbyte;
  10627. X    else
  10628. X        size &= ~511L;
  10629. X
  10630. X    rab->rab$l_ubf = buf;
  10631. X    rab->rab$w_usz = size;
  10632. X    status = sys$read(rab);
  10633. X    if (!ERR(status) && rab->rab$w_rsz > 0)
  10634. X    {
  10635. X        ctx -> status = 0;
  10636. X        ctx -> rest -= rab->rab$w_rsz;
  10637. X        return rab->rab$w_rsz;
  10638. X    }
  10639. X    else
  10640. X    {
  10641. X        ctx->status = (status==RMS$_EOF ? 0:status);
  10642. X        if(status == RMS$_EOF)
  10643. X                ctx -> rest = 0L;
  10644. X        return 0;
  10645. X    }
  10646. X}
  10647. X
  10648. X/**************************
  10649. X *   Function vms_error   *
  10650. X **************************/
  10651. Xint vms_error(rab)
  10652. X    struct RAB *rab;
  10653. X{
  10654. X    if (!CHECK_RAB(rab))
  10655. X        return RET_ERROR;
  10656. X    return ((Ctxptr) (rab->rab$l_ctx))->status;
  10657. X}
  10658. X
  10659. X
  10660. Xdump_rms_block(p)
  10661. X    unsigned char *p;
  10662. X{
  10663. X    unsigned char bid, len;
  10664. X    int err;
  10665. X    char *type;
  10666. X    char buf[132];
  10667. X    int i;
  10668. X
  10669. X    err = 0;
  10670. X    bid = p[0];
  10671. X    len = p[1];
  10672. X    switch (bid)
  10673. X    {
  10674. X        case FAB$C_BID:
  10675. X            type = "FAB";
  10676. X            break;
  10677. X        case XAB$C_ALL:
  10678. X            type = "xabALL";
  10679. X            break;
  10680. X        case XAB$C_KEY:
  10681. X            type = "xabKEY";
  10682. X            break;
  10683. X        case XAB$C_DAT:
  10684. X            type = "xabDAT";
  10685. X            break;
  10686. X        case XAB$C_RDT:
  10687. X            type = "xabRDT";
  10688. X            break;
  10689. X        case XAB$C_FHC:
  10690. X            type = "xabFHC";
  10691. X            break;
  10692. X        case XAB$C_PRO:
  10693. X            type = "xabPRO";
  10694. X            break;
  10695. X        default:
  10696. X            type = "Unknown";
  10697. X            err = 1;
  10698. X            break;
  10699. X    }
  10700. X    printf("Block @%08X of type %s (%d).", p, type, bid);
  10701. X    if (err)
  10702. X    {
  10703. X        printf("\n");
  10704. X        return;
  10705. X    }
  10706. X    printf(" Size = %d\n", len);
  10707. X    printf(" Offset - Hex - Dec\n");
  10708. X    for (i = 0; i < len; i += 8)
  10709. X    {
  10710. X        int j;
  10711. X        printf("%3d - ", i);
  10712. X        for (j = 0; j < 8; j++)
  10713. X            if (i + j < len)
  10714. X                printf("%02X ", p[i + j]);
  10715. X            else
  10716. X                printf("   ");
  10717. X        printf(" - ");
  10718. X        for (j = 0; j < 8; j++)
  10719. X            if (i + j < len)
  10720. X                printf("%03d ", p[i + j]);
  10721. X            else
  10722. X                printf("    ");
  10723. X        printf("\n");
  10724. X    }
  10725. X}
  10726. X
  10727. X#ifdef OLD_COMPRESS
  10728. X# define BC_METHOD      BC_00
  10729. X# define        COMP_BLK(to,tos,from,froms) _compress( from,to,froms )
  10730. X#else
  10731. X# define BC_METHOD      BC_DEFL
  10732. X# define        COMP_BLK(to,tos,from,froms) memcompress(to,tos,from,froms)
  10733. X#endif
  10734. X
  10735. Xstatic uch *_compress_block(to,from,size,sig)
  10736. Xregister struct extra_block *to;
  10737. Xuch *from,*sig;
  10738. Xint size;
  10739. X{                               
  10740. X        ulg cl;
  10741. X        to -> im_sig =  *(ush*)SIGNATURE;
  10742. X        to -> block_sig =       *(ulg*)(sig);
  10743. X        to -> flags =           BC_METHOD;
  10744. X        to -> length =  size;
  10745. X#ifdef DEBUG
  10746. X        printf("\nmemcompr(%d,%d,%d,%d)\n",&(to->body[0]),size+PAD,from,size);
  10747. X#endif
  10748. X        cl = COMP_BLK( &(to->body[0]), size+PAD, from, size );
  10749. X#ifdef DEBUG
  10750. X        printf("Compressed to %d\n",cl);
  10751. X#endif
  10752. X        if( cl >= size )
  10753. X        {       memcpy(&(to->body[0]), from, size);
  10754. X                to->flags = BC_STORED;
  10755. X                cl = size;
  10756. X#ifdef DEBUG
  10757. X                printf("Storing block...\n");
  10758. X#endif
  10759. X        }
  10760. X        return (uch*)(to) + (to->size = cl + EXTBSL + RESL) + 4;
  10761. X}
  10762. X
  10763. X#define NBITS 32
  10764. X
  10765. Xstatic int _compress(from,to,size)
  10766. Xuch *from,*to;
  10767. Xint size;
  10768. X{
  10769. X    int off=0;
  10770. X    ulg bitbuf=0;
  10771. X    int bitcnt=0;
  10772. X    int i;
  10773. X
  10774. X#define _BIT(val,len)   {                       \
  10775. X        if(bitcnt + (len) > NBITS)              \
  10776. X            while(bitcnt >= 8)                  \
  10777. X            {                                   \
  10778. X                to[off++] = (uch)bitbuf;        \
  10779. X                bitbuf >>= 8;                   \
  10780. X                bitcnt -= 8;                    \
  10781. X            }                                   \
  10782. X        bitbuf |= ((ulg)(val))<<bitcnt;         \
  10783. X        bitcnt += len;                          \
  10784. X    }
  10785. X
  10786. X#define _FLUSH  {                               \
  10787. X            while(bitcnt>0)                     \
  10788. X            {                                   \
  10789. X                to[off++] = (uch)bitbuf;        \
  10790. X                bitbuf >>= 8;                   \
  10791. X                bitcnt -= 8;                    \
  10792. X            }                                   \
  10793. X        }
  10794. X
  10795. X    for(i=0; i<size; i++)
  10796. X    {
  10797. X        if( from[i] )
  10798. X        {
  10799. X                _BIT(1,1);
  10800. X                _BIT(from[i],8);
  10801. X        }
  10802. X        else
  10803. X            _BIT(0,1);
  10804. X    }
  10805. X    _FLUSH;
  10806. X    return off;
  10807. X}
  10808. X
  10809. X#endif                          /* ?VMS */
  10810. END_OF_FILE
  10811.   if test 18616 -ne `wc -c <'vms/vms.c'`; then
  10812.     echo shar: \"'vms/vms.c'\" unpacked with wrong size!
  10813.   fi
  10814.   # end of 'vms/vms.c'
  10815. fi
  10816. if test -f 'vms/vms_zip.rnh' -a "${1}" != "-c" ; then 
  10817.   echo shar: Will not clobber existing file \"'vms/vms_zip.rnh'\"
  10818. else
  10819.   echo shar: Extracting \"'vms/vms_zip.rnh'\" \(18026 characters\)
  10820.   sed "s/^X//" >'vms/vms_zip.rnh' <<'END_OF_FILE'
  10821. X.!
  10822. X.!  File:    ZIP.RNH
  10823. X.!
  10824. X.!  Author:    Hunter Goatley
  10825. X.!
  10826. X.!  Date:    October 22, 1991
  10827. X.!
  10828. X.!  Description:
  10829. X.!
  10830. X.!    RUNOFF source file for portable ZIP on-line help for VMS.
  10831. X.!    Adapted from ZIP.DOC, distributed with ZIP.
  10832. X.!
  10833. X.!    To build:    $ RUNOFF ZIP.RNH
  10834. X.!            $ LIBR/HELP/INSERT libr ZIP
  10835. X.!
  10836. X.!  Modification history:
  10837. X.!
  10838. X.!    Hunter Goatley        22-OCT-1991 20:45
  10839. X.!        Genesis.
  10840. X.!    Jean-loup Gailly    25 March 92
  10841. X.!        Adaptation to zip 1.6.
  10842. X.!    Igor Mandrichenko    9-JUN-1992
  10843. X.!        Added explanation of -V option.
  10844. X.!    Jean-loup Gailly    14 June 92
  10845. X.!        Adaptation to zip 1.8.
  10846. X.!    Jean-loup Gailly    20 Aug 92
  10847. X.!        Adaptation to zip 1.9.
  10848. X.!
  10849. X.noflags
  10850. X.lm4 .rm72
  10851. X.indent -4
  10852. X1 ZIP
  10853. X.br
  10854. XZip is a compression and file packaging utility for Unix, MSDOS, OS/2, and
  10855. XVMS.  It is analogous to a combination of tar and compress and is
  10856. Xcompatible with PKZIP (Phil Katz ZIP) for MSDOS systems.
  10857. X.sk
  10858. XThere is a companion to Zip called UnZip (of course).  Zip and UnZip can
  10859. Xwork with files produced by PKZIP under MSDOS, and PKZIP and PKUNZIP can
  10860. Xwork with files produced by Zip.
  10861. X.sk
  10862. XZip 1.9 is compatible with PKZIP 1.93a.
  10863. XNote that pkunzip 1.10 cannot extract files produced by pkzip 1.93a
  10864. Xor zip 1.9. You must use pkzip 1.93a or unzip 5.0 to extract them.
  10865. X.sk
  10866. XFor a brief help on Zip and Unzip, run each without specifying any
  10867. Xparameters on the command line.
  10868. X.sk
  10869. XZip puts one or more compressed files into a single "zip file" along with
  10870. Xinformation about the files, including the name, path if requested, date
  10871. Xand time last modified, protection, and check information to verify the
  10872. Xfidelity of each entry.  Zip can pack an entire directory structure in a
  10873. Xzip file with a single command.  Compression ratios of 2:1 to 3:1 are
  10874. Xcommon for text files.  Zip has has one compression method (deflation) and
  10875. Xcan also store files without compression. It automatically chooses the better
  10876. Xof the two for each file to be compressed.
  10877. X.sk
  10878. XZip is useful for packaging a set of files to send to someone or for
  10879. Xdistribution; for archiving or backing up files; and for saving disk space
  10880. Xby temporarily compressing unused files or directories.
  10881. X.sk
  10882. XFormat:
  10883. X.sk;.lm+1;.literal
  10884. XZIP [-options] [-b path] [-n suffixes] [-t mmddyy] zipfile file(s) [-x list]
  10885. X.end literal;.lm-1
  10886. X.!------------------------------------------------------------------------------
  10887. X.indent -4
  10888. X2 Options
  10889. X.br
  10890. XThe default action of Zip is to add or replace zipfile entries from list, which
  10891. Xcan include the special name -@ to read names from SYS$INPUT.  The following
  10892. Xlist of options was taken from the on-line help generated when Zip is run
  10893. Xwithout any command-line parameters:
  10894. X.sk
  10895. X.literal
  10896. X  -f   freshen: only changed files
  10897. X  -d   delete entries in zipfile
  10898. X  -k   simulate PKZIP made zipfile
  10899. X  -h   show this help
  10900. X  -r   recurse into directories
  10901. X  -q   quiet operation
  10902. X  -c   add one-line comments
  10903. X  -b   use "path" for temp files
  10904. X  -o   make zipfile as old as latest entry
  10905. X  -w   append the VMS version number to name stored in zip file
  10906. X  -x   exclude the names that follow from those operated on
  10907. X  -u   update: only changed or new files
  10908. X  -m   move into zipfile (delete files)
  10909. X  -g   allow growing existing zipfile
  10910. X  -l   translate end-of-lines
  10911. X  -j   junk (don't record) directory names
  10912. X  -0   store only
  10913. X  -1   compress faster
  10914. X  -9   compress better
  10915. X  -n   don't compress theses suffixes
  10916. X  -z   add zipfile comment
  10917. X  -t   only do files after "mmddyy"
  10918. X  -L   show software license
  10919. X  -V   save VMS file attributes
  10920. X.end literal
  10921. X.!------------------------------------------------------------------------------
  10922. X.indent -4
  10923. X2 How_To_Use_Zip
  10924. X.br
  10925. XThe simplest use of Zip is as follows:
  10926. X.sk;.indent 10;$ zip stuff *
  10927. X.sk
  10928. XThis will create the file "STUFF.ZIP" (assuming it does not exist) and put
  10929. Xall the files in the current directory in STUFF.ZIP in a compressed form.
  10930. XThe .ZIP suffix is added automatically, unless that file name given
  10931. Xcontains a dot already.  This allows specifying suffixes other than ".ZIP".
  10932. X.sk
  10933. XTo zip up an entire directory, the command:
  10934. X.sk;.indent 10
  10935. X$ zip -r foo *.*
  10936. X.sk
  10937. Xwill create the file "FOO.ZIP" containing all the files and directories in
  10938. Xthe in the current directory.  The "r" option means recurse through the
  10939. Xdirectory structure.
  10940. X.sk
  10941. XYou may want to make a zip file that contains the files in [.FOO], but not
  10942. Xrecord the directory name, FOO.  You can use the -j (junk path) option to
  10943. Xleave off the path:
  10944. X.sk;.indent 10
  10945. X$ zip -j foo [.foo]*.*
  10946. X.sk
  10947. XYou might be zipping to save disk space, in which case you could:
  10948. X.sk;.indent 10
  10949. X$ zip -rm foo *.txt
  10950. X.sk
  10951. Xwhere the "m" option means "move".  This will delete all files matching
  10952. X*.txt after making FOO.ZIP.  No deletions will be done until the zip has
  10953. Xcompleted with no errors.  This option is obviously more dangerous and
  10954. Xshould be used with care.
  10955. X.sk
  10956. XIf the zip file already exists, these commands will replace existing or add
  10957. Xnew entries to the zip file.  For example, if you were really short on disk
  10958. Xspace, you might not have enough room simultaneously to hold the directory
  10959. X[.FOO] and the compressed FOO.ZIP.  In this case, you could do it in steps.
  10960. XIf [.FOO] contained the subdirectories [.TOM], [.DICK], and [.HARRY], then
  10961. Xyou could:
  10962. X.sk;
  10963. X.indent 10;$ zip -rm foo [.foo.tom]
  10964. X.indent 10;$ zip -rm foo [.foo.dick]
  10965. X.indent 10;$ zip -rm foo [.foo.harry]
  10966. X.sk
  10967. Xwhere the first command would create FOO.ZIP, and the next two would add to
  10968. Xit.  At the completion of each zip command, the files in the directory just
  10969. Xzipped would be deleted, making room in which the next Zip command could
  10970. Xwork.
  10971. X.!------------------------------------------------------------------------------
  10972. X.indent -4
  10973. X2 Modifying_Existing_Zip_Files
  10974. X.br
  10975. XWhen given the name of an existing zip file with the above commands, Zip
  10976. Xwill replace identically named entries in the Zip file or add entries for
  10977. Xnew names.  For example, if FOO.ZIP exists and contains foo/file1 and
  10978. Xfoo/file2, and the directory [.FOO] contains the files foo/file1 and
  10979. Xfoo/file3, then:
  10980. X.sk;.indent 10
  10981. X$ zip -r foo foo
  10982. X.sk
  10983. Xwill replace foo/file1 in foo.zip and add foo/file3 to FOO.ZIP.  After
  10984. Xthis, FOO.ZIP contains foo/file1, foo/file2, and foo/file3, with foo/file2
  10985. Xunchanged from before.
  10986. X.sk
  10987. XWhen changing an existing zip file, Zip will write a temporary file with
  10988. Xthe new contents, and only replace the old one when the zip has completed
  10989. Xwith no errors. You can use
  10990. Xthe -b option to specify a different path (usually a different dev- ice) to
  10991. Xput the temporary files in.  For example:
  10992. X.sk;.indent 10
  10993. X$ zip -b scratch$:[tmp] stuff *
  10994. X.sk
  10995. Xwill put the temporary zip file and the temporary compression files in the
  10996. Xdirectory "SCRATCH$:[TMP]", copying over STUFF.ZIP in the current directory
  10997. Xwhen done.
  10998. X.sk
  10999. XIf you are only adding entries to a zip file, not replacing, and the -g
  11000. Xoption is given, then Zip grows (appends to) the file instead of copying
  11001. Xit.  The danger of this is that if the operation fails, the original zip
  11002. Xfile is corrupted and lost.
  11003. X.sk
  11004. XThere are two other ways to change or add entries in a zip file that are
  11005. Xrestrictions of simple addition or replacement.  The first is -u (update)
  11006. Xwhich will add new entries to the zip file as before but will replace
  11007. Xexisting entries only if the modified date of the file is more recent than
  11008. Xthe date recorded for that name in the zip file.  For example:
  11009. X.sk;.indent 10
  11010. X$ zip -u stuff *
  11011. X.sk
  11012. Xwill add any new files in the current directory, and update any changed
  11013. Xfiles in the zip file STUFF.ZIP.  Note that Zip will not try to pack
  11014. XSTUFF.ZIP into itself when you do this. Zip will always exclude the zip
  11015. Xfile from the files on which to be operated.
  11016. X.sk
  11017. XThe second restriction is -f (freshen) which, like update, will only
  11018. Xreplace entries with newer files; unlike update, will not add files that
  11019. Xare not already in the zip file. For this option, you may want to simply
  11020. Xfreshen all of the files that are in the specified zip file.  To do this
  11021. Xyou would simply:
  11022. X.sk;.indent 10
  11023. X$ zip -f foo
  11024. X.sk
  11025. XNote that the -f option with no arguments freshens all the entries in the
  11026. Xzip file.  The same is true of -u, and hence "zip -u foo" and "zip -f foo"
  11027. Xboth do the same thing.
  11028. X.sk
  11029. XThis command should be run from the same directory from which the original
  11030. Xzip command was run, since paths stored in zip files are always relative.
  11031. X.sk
  11032. XAnother restriction that can be used with adding, updating, or freshening
  11033. Xis -t (time), which will not operate on files modified earlier than the
  11034. Xspecified date.  For example:
  11035. X.sk;.indent 10
  11036. X$ zip -rt 120791 infamy [.FOO]*.*
  11037. X.sk
  11038. Xwill add all the files in [.FOO] and its subdirectories that were last
  11039. Xmodified on December 7, 1991, or later to the zip file INFAMY.ZIP.
  11040. X.sk
  11041. XAlso, files can be explicitly excluded using the -x option:
  11042. X.sk;.indent 10
  11043. X$ zip -r foo [.FOO] -x *.obj
  11044. X.sk
  11045. Xwhich will zip up the contents of [.FOO] into FOO.ZIP but exclude all the
  11046. Xfiles that end in ".OBJ".
  11047. X.sk
  11048. XThe last operation is -d (delete) which will remove entries from a zip
  11049. Xfile.  An example might be:
  11050. X.sk;.indent 10
  11051. X$ zip -d foo foo/harry/*.* *.obj
  11052. X.sk
  11053. Xwhich will remove all of the files that start with "foo/harry/" and all of
  11054. Xthe files that end with ".OBJ" (in any path).
  11055. X.sk
  11056. XUnder MSDOS, -d is case sensitive when it matches names in the zip file.
  11057. XThis allows deleting names that were zipped on other systems, but requires
  11058. Xthat the names be entered in upper case if they were zipped on an MSDOS
  11059. Xsystem, so that the names can be found in the zip file and deleted.
  11060. X.!------------------------------------------------------------------------------
  11061. X.indent -4
  11062. X2 More_Options
  11063. X.br
  11064. XAs mentioned before, Zip will use the best of two methods: deflate or store.
  11065. XThe option -0 will force Zip to use store on all files. For example:
  11066. X.sk;.indent 10
  11067. Xzip -r0 foo foo
  11068. X.sk
  11069. Xwill zip up the directory foo into foo.zip using only store.
  11070. X.sk
  11071. XThe speed of deflation can also be controlled with options -1 (fastest
  11072. Xmethod but less compression) to -9 (best compression but slower). The
  11073. Xdefault value is -5. For example:
  11074. X.sk;.indent 10
  11075. Xzip -r8 foo foo
  11076. X.sk
  11077. XIn nearly all cases, a file that is already compressed cannot be compressed
  11078. Xfurther by Zip, or if it can, the effect is minimal.  The -n option
  11079. Xprevents Zip from trying to compress files that have the
  11080. Xgiven suffixes.  Such files are simply stored (0%
  11081. Xcompression) in the
  11082. Xoutput zip file, so that Zip doesn't waste its time trying to compress
  11083. Xthem. The suffixes are separated by
  11084. Xeither colons or semicolons.  For example, in DCL:
  11085. X.sk
  11086. X.indent 10;$ zip -rn ".Z:.zip:.tiff:.gif:.snd" foo [.FOO]*.*
  11087. X.sk
  11088. Xwill put everything in [.FOO] into FOO.ZIP, but will store any files that end
  11089. Xin .Z, .ZIP, .TIFF, .GIF, or .SND without trying to compress them.  (Image and
  11090. Xsound files often have their own specialized compression methods.)
  11091. XThe default suffix list is ".Z:.zip;.zoo:.arc:.lzh:.arj".
  11092. XThe environment variable ZIPOPT can be used to change this default. For
  11093. Xexample:
  11094. X.sk
  11095. X.indent 10;$ ZIPOPT == "-n .Z:.zip:.tiff:.gif:.snd"
  11096. X.sk
  11097. XThe variable ZIPOPT can be used for any option and can include several
  11098. Xoptions.
  11099. X.sk
  11100. XUnder Unix and under OS/2 (if files from a HPFS are stored), Zip will store
  11101. Xthe full path (relative to the current path) and name of the file (or just
  11102. Xthe name if -j is specified) in the zip file along with the Unix
  11103. Xattributes, and it will mark the entry as made under Unix.  If the zip file
  11104. Xis intended for PKUNZIP under MSDOS, then the -k (Katz) option should be
  11105. Xused to attempt to convert the names and paths to conform to MSDOS, store
  11106. Xonly the MSDOS attribute (just the user write attribute from Unix), and
  11107. Xmark the entry as made under MSDOS (even though it wasn't).
  11108. X.sk
  11109. XThe -o (older) option will set the "last modified" time of the zip file to
  11110. Xthe latest "last modified" time of the entries in the zip file.  This can
  11111. Xbe used without any other operations, if desired.  For example:
  11112. X.sk;.indent 10
  11113. X$ zip -o foo
  11114. X.sk
  11115. Xwill change the last modified time of FOO.ZIP to the latest time of the
  11116. Xentries in FOO.ZIP.
  11117. X.sk
  11118. XThe -e and -c options operate on all files updated or added to the zip
  11119. Xfile.  Encryption (-e) will prompt for a password on the terminal and will
  11120. Xnot echo the password as it is typed (if stderr is not a TTY, Zip will exit
  11121. Xwith an error). New zip entries will be encrypted using that password.  For
  11122. Xadded peace of mind, you can use -ee, which will prompt for the password
  11123. Xtwice, checking that the two are the same before using it.
  11124. X.sk
  11125. XOne-line comments can be added for each file with the -c option.  The zip
  11126. Xfile operations (adding or updating) will be done first, and you will then
  11127. Xbe prompted for a one-line comment for each file.  You can then enter the
  11128. Xcomment followed by return, or just return for no comment.
  11129. X.sk
  11130. XThe -z option will prompt you for a multi-line comment for the entire zip
  11131. Xfile.  This option can be used by itself, or in combination with other
  11132. Xoptions.  The comment is ended by a line containing just a period, or an
  11133. Xend of file condition (^D on Unix, ^Z on MSDOS, OS/2, and VAX/VMS).
  11134. X.sk
  11135. XThe -q (quiet) option eliminates the informational messages and comment
  11136. Xprompts while Zip is operating.  This might be used in shell scripts, for
  11137. Xexample, or if the zip operation is being performed as a background task
  11138. X("$ spawn/nowait zip -q foo *.c").
  11139. X.sk
  11140. XZip can take a list of file names to operate on from SYS$INPUT using the
  11141. X"-@"
  11142. Xoption.
  11143. X.!  In Unix, this option can be used with the find command to extend
  11144. X.!greatly the functionality of Zip. For example, to zip up all the C source
  11145. X.!files in the current directory and its subdirectories, you can:
  11146. X.!.sk
  11147. X.!find . -type f -name "*.[ch]" -print | zip source -@
  11148. X.!.sk
  11149. X.!Note that the pattern must be quoted to keep the shell from expanding it.
  11150. X.sk
  11151. XUnder VMS only, the -w option will append the version number of the files
  11152. Xto the name and zip up multiple versions of files.  Without -w, Zip will
  11153. Xonly use the most recent version of the specified file(s).
  11154. X.sk
  11155. XOne more option that valid only under VMS is -V option. This option saves
  11156. Xall (hopefully) file attributes needed to make EXACT copy of the
  11157. Xfile after extraction from archive. To extract a file with saved attributes
  11158. Xuse UnZip version 4.2 or later. Note that to specify this option you should
  11159. Xquote it ("-V"). Be carefull: it's rather hard (if possible at all) to extract
  11160. Xa file archived on VMS with this option specified on other systems. See 
  11161. Xdocumentation on UnZip for further information.
  11162. X.sk
  11163. XThe -l option translates the Unix end-of-line character LF into the
  11164. XMSDOS convention CR LF. This option should not be used on binary files.
  11165. XThis option can be used on Unix if the zip file is intended for PKUNZIP
  11166. Xunder MSDOS.
  11167. X.sk
  11168. XIf Zip is run with the -h option, or with no arguments and standard output is
  11169. Xa terminal, the license and the command-argument and option help is shown.
  11170. XThe -L option just shows the license.
  11171. X.!------------------------------------------------------------------------------
  11172. X.indent -4
  11173. X2 Copyright
  11174. X.br
  11175. X     Copyright (C) 1990,1991 Mark Adler, Richard B. Wales, Jean-loup Gailly,
  11176. X     Igor Mandrichenko and Kai Uwe Rommel. Permission is granted to any
  11177. X     individual or institution to use, copy, or redistribute this software
  11178. X     so long as all of the original files are included unmodified,
  11179. X     that it is not sold for profit, and that this copyright
  11180. X     notice is retained.
  11181. X.!------------------------------------------------------------------------------
  11182. X.indent -4
  11183. X2 Acknowledgements
  11184. X.br
  11185. X     Thanks to R. P. Byrne for his Shrink.Pas program which
  11186. X     inspired this project; to Phil Katz for making the zip file format,
  11187. X     compression format, and .ZIP filename extension all public
  11188. X     domain; to Steve Burg and Phil Katz for help on unclear points of
  11189. X     the deflate format; to Keith Petersen for providing a mailing list and
  11190. X     ftp site for the INFO-ZIP group to use; and most importantly, to
  11191. X     the INFO-ZIP group itself (listed in the file
  11192. X     infozip.who) without whose tireless testing and bug-fixing
  11193. X     efforts a portable Zip would not have been possible.
  11194. X     Finally we should thank (blame) the INFO-ZIP moderator,
  11195. X     David Kirschbaum for getting us into this mess in the first
  11196. X     place.
  11197. X.!------------------------------------------------------------------------------
  11198. X.indent -4
  11199. X2 Bugs
  11200. X.sk
  11201. X     WARNING: zip files produced by this version of zip must not be
  11202. X     *updated* by zip 1.0 or pkzip 1.10 or pkzip 1.93a, if they contain
  11203. X     encrypted members, or if they have been produced in a pipe or on a non
  11204. X     seekable device. The old versions of zip or pkzip would destroy the
  11205. X     zip structure. The old versions can list the contents of the zip file
  11206. X     but cannot extract it anyway (because of the new compression algorithm).
  11207. X     If you do not use encryption and use regular disk files, you do
  11208. X     not have to care about this problem.
  11209. X.sk
  11210. X     Under VMS, not all of the odd file formats are treated properly.  Only
  11211. X     zip files of format stream-LF and fixed length 512 are expected to work
  11212. X     with Zip.  Others can be converted using Rahul Dhesi's BILF
  11213. X     program.  This version of Zip does handle some of the
  11214. X     conversion internally.
  11215. X     When using Kermit to transfer zip files from Vax to MSDOS, type "set
  11216. X     file type block" on the Vax.  When transfering from MSDOS to Vax, type
  11217. X     "set file type fixed" on the Vax.  In both cases, type "set file type
  11218. X     binary" on MSDOS.
  11219. X.sk
  11220. X     Under VMS, zip hangs for file specification that uses DECnet
  11221. X     syntax (foo::*.*).
  11222. X.sk
  11223. X     LIKE ANYTHING ELSE THAT'S FREE, ZIP AND ITS ASSOCIATED UTILITIES
  11224. X     ARE PROVIDED AS IS AND COME WITH NO WARRANTY OF ANY
  11225. X     KIND, EITHER EXPRESSED OR IMPLIED. IN NO EVENT WILL THE
  11226. X     COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES RESULTING FROM
  11227. X     THE USE OF THIS SOFTWARE.
  11228. X.sk
  11229. X     That having been said, please send any problems or comments
  11230. X     via email to the Internet address zip-bugs@cs.ucla.edu.  For
  11231. X     bug reports, please include the version of Zip, the make
  11232. X     options you used to compile it, the machine and operating
  11233. X     system you are using, and as much additional information as
  11234. X     possible.  Thank you for your support.
  11235. X.!------------------------------------------------------------------------------
  11236. END_OF_FILE
  11237.   if test 18026 -ne `wc -c <'vms/vms_zip.rnh'`; then
  11238.     echo shar: \"'vms/vms_zip.rnh'\" unpacked with wrong size!
  11239.   fi
  11240.   # end of 'vms/vms_zip.rnh'
  11241. fi
  11242. if test -f 'zipsplit.c' -a "${1}" != "-c" ; then 
  11243.   echo shar: Will not clobber existing file \"'zipsplit.c'\"
  11244. else
  11245.   echo shar: Extracting \"'zipsplit.c'\" \(17114 characters\)
  11246.   sed "s/^X//" >'zipsplit.c' <<'END_OF_FILE'
  11247. X/*
  11248. X
  11249. X Copyright (C) 1990-1992 Mark Adler, Richard B. Wales, Jean-loup Gailly,
  11250. X Kai Uwe Rommel and Igor Mandrichenko.
  11251. X Permission is granted to any individual or institution to use, copy, or
  11252. X redistribute this software so long as all of the original files are included
  11253. X unmodified, that it is not sold for profit, and that this copyright notice
  11254. X is retained.
  11255. X
  11256. X*/
  11257. X
  11258. X/*
  11259. X *  zipsplit.c by Mark Adler.
  11260. X */
  11261. X
  11262. X#define UTIL
  11263. X#include "revision.h"
  11264. X#include "zip.h"
  11265. X#include <signal.h>
  11266. X
  11267. X#define DEFSIZ 36000L   /* Default split size (change in help() too) */
  11268. X#ifdef MSDOS
  11269. X#  define NL 2          /* Number of bytes written for a \n */
  11270. X#else /* !MSDOS */
  11271. X#  define NL 1          /* Number of bytes written for a \n */
  11272. X#endif /* ?MSDOS */
  11273. X#define INDEX "zipsplit.idx"    /* Name of index file */
  11274. X
  11275. X
  11276. X/* Local functions */
  11277. X#ifdef PROTO
  11278. X   local void handler(int);
  11279. X   local void license(void);
  11280. X   local void help(void);
  11281. X   local extent simple(ulg *, extent, ulg, ulg);
  11282. X   local int descmp(voidp *, voidp *);
  11283. X   local extent greedy(ulg *, extent, ulg, ulg);
  11284. X   void main(int, char **);
  11285. X#endif /* PROTO */
  11286. X
  11287. X
  11288. X/* Output zip files */
  11289. Xlocal char template[16];        /* name template for output files */
  11290. Xlocal int zipsmade = 0;         /* number of zip files made */
  11291. Xlocal int indexmade = 0;        /* true if index file made */
  11292. Xlocal char *path = NULL;        /* space for full name */
  11293. Xlocal char *name;               /* where name goes in path[] */
  11294. X
  11295. X
  11296. Xvoid err(c, h)
  11297. Xint c;                  /* error code from the ZE_ class */
  11298. Xchar *h;                /* message about how it happened */
  11299. X/* Issue a message for the error, clean up files and memory, and exit. */
  11300. X{
  11301. X  if (PERR(c))
  11302. X    perror("zipsplit error");
  11303. X  fprintf(stderr, "zipsplit error: %s (%s)\n", errors[c-1], h);
  11304. X  if (indexmade)
  11305. X  {
  11306. X    strcpy(name, INDEX);
  11307. X    destroy(path);
  11308. X  }
  11309. X  for (; zipsmade; zipsmade--)
  11310. X  {
  11311. X    sprintf(name, template, zipsmade);
  11312. X    destroy(path);
  11313. X  }
  11314. X  if (path != NULL)
  11315. X    free((voidp *)path);
  11316. X  if (zipfile != NULL)
  11317. X    free((voidp *)zipfile);
  11318. X#ifdef VMS
  11319. X  exit(0);
  11320. X#else /* !VMS */
  11321. X  exit(c);
  11322. X#endif /* ?VMS */
  11323. X}
  11324. X
  11325. X
  11326. X
  11327. Xlocal void handler(s)
  11328. Xint s;                  /* signal number (ignored) */
  11329. X/* Upon getting a user interrupt, abort cleanly using err(). */
  11330. X{
  11331. X#ifndef MSDOS
  11332. X  putc('\n', stderr);
  11333. X#endif /* !MSDOS */
  11334. X  err(ZE_ABORT, "aborting");
  11335. X  s++;                                  /* keep some compilers happy */
  11336. X}
  11337. X
  11338. X
  11339. Xvoid warn(a, b)
  11340. Xchar *a, *b;            /* message strings juxtaposed in output */
  11341. X/* Print a warning message to stderr and return. */
  11342. X{
  11343. X  fprintf(stderr, "zipsplit warning: %s%s\n", a, b);
  11344. X}
  11345. X
  11346. X
  11347. Xlocal void license()
  11348. X/* Print license information to stdout. */
  11349. X{
  11350. X  extent i;             /* counter for copyright array */
  11351. X
  11352. X  for (i = 0; i < sizeof(copyright)/sizeof(char *); i++) {
  11353. X    printf(copyright[i], "zipsplit");
  11354. X    putchar('\n');
  11355. X  }
  11356. X  for (i = 0; i < sizeof(disclaimer)/sizeof(char *); i++)
  11357. X    puts(disclaimer[i]);
  11358. X}
  11359. X
  11360. X
  11361. Xlocal void help()
  11362. X/* Print help (along with license info) to stdout. */
  11363. X{
  11364. X  extent i;             /* counter for help array */
  11365. X
  11366. X  /* help array */
  11367. X  static char *text[] = {
  11368. X"",
  11369. X"ZipSplit %d.%d (%s)",
  11370. X"Usage:  zipsplit [-ti] [-n size] [-b path] zipfile",
  11371. X"  -t   report how many files it will take, but don't make them",
  11372. X"  -i   make index (zipsplit.idx) and count its size against first zip file",
  11373. X"  -n   make zip files no larger than \"size\" (default = 36000)",
  11374. X"  -b   use \"path\" for the output zip files",
  11375. X"  -s   do a sequential split even if it takes more zip files",
  11376. X"  -h   show this help               -L   show software license"
  11377. X  };
  11378. X
  11379. X  for (i = 0; i < sizeof(copyright)/sizeof(char *); i++) {
  11380. X    printf(copyright[i], "zipsplit");
  11381. X    putchar('\n');
  11382. X  }
  11383. X  for (i = 0; i < sizeof(text)/sizeof(char *); i++)
  11384. X  {
  11385. X    printf(text[i], REVISION / 10, REVISION % 10, REVDATE);
  11386. X    putchar('\n');
  11387. X  }
  11388. X}
  11389. X
  11390. X
  11391. Xlocal extent simple(a, n, c, d)
  11392. Xulg *a;         /* items to put in bins, return value: destination bins */
  11393. Xextent n;       /* number of items */
  11394. Xulg c;          /* capacity of each bin */
  11395. Xulg d;          /* amount to deduct from first bin */
  11396. X/* Return the number of bins of capacity c that are needed to contain the
  11397. X   integers in a[0..n-1] placed sequentially into the bins.  The value d
  11398. X   is deducted initially from the first bin (space for index).  The entries
  11399. X   in a[] are replaced by the destination bins. */
  11400. X{
  11401. X  extent k;     /* current bin number */
  11402. X  ulg t;        /* space used in current bin */
  11403. X
  11404. X  t = k = 0;
  11405. X  while (n--)
  11406. X  {
  11407. X    if (*a + t > c - (k == 0 ? d : 0))
  11408. X    {
  11409. X      k++;
  11410. X      t = 0;
  11411. X    }
  11412. X    t += *a;
  11413. X    *(ulg huge *)a++ = k;
  11414. X  }
  11415. X  return k + 1;
  11416. X}
  11417. X
  11418. X
  11419. Xlocal int descmp(a, b)
  11420. Xvoidp *a, *b;           /* pointers to pointers to ulg's to compare */
  11421. X/* Used by qsort() in greedy() to do a descending sort. */
  11422. X{
  11423. X  return **(ulg **)a < **(ulg **)b ? 1 : (**(ulg **)a > **(ulg **)b ? -1 : 0);
  11424. X}
  11425. X
  11426. X
  11427. Xlocal extent greedy(a, n, c, d)
  11428. Xulg *a;         /* items to put in bins, return value: destination bins */
  11429. Xextent n;       /* number of items */
  11430. Xulg c;          /* capacity of each bin */
  11431. Xulg d;          /* amount to deduct from first bin */
  11432. X/* Return the number of bins of capacity c that are needed to contain the
  11433. X   items with sizes a[0..n-1] placed non-sequentially into the bins.  The
  11434. X   value d is deducted initially from the first bin (space for index).
  11435. X   The entries in a[] are replaced by the destination bins. */
  11436. X{
  11437. X  ulg *b;       /* space left in each bin (malloc'ed for each m) */
  11438. X  ulg *e;       /* copy of argument a[] (malloc'ed) */
  11439. X  extent i;     /* steps through items */
  11440. X  extent j;     /* steps through bins */
  11441. X  extent k;     /* best bin to put current item in */
  11442. X  extent m;     /* current number of bins */
  11443. X  ulg **s;      /* pointers to e[], sorted descending (malloc'ed) */
  11444. X  ulg t;        /* space left in best bin (index k) */
  11445. X
  11446. X  /* Algorithm:
  11447. X     1. Copy a[] to e[] and sort pointers to e[0..n-1] (in s[]), in
  11448. X        descending order.
  11449. X     2. Compute total of s[] and set m to the smallest number of bins of
  11450. X        capacity c that can hold the total.
  11451. X     3. Allocate m bins.
  11452. X     4. For each item in s[], starting with the largest, put it in the
  11453. X        bin with the smallest current capacity greater than or equal to the
  11454. X        item's size.  If no bin has enough room, increment m and go to step 4.
  11455. X     5. Else, all items ended up in a bin--return m.
  11456. X  */
  11457. X
  11458. X  /* Copy a[] to e[], put pointers to e[] in s[], and sort s[].  Also compute
  11459. X     the initial number of bins (minus 1). */
  11460. X  if ((e = (ulg *)malloc(n * sizeof(ulg))) == NULL ||
  11461. X      (s = (ulg **)malloc(n * sizeof(ulg *))) == NULL)
  11462. X  {
  11463. X    if (e != NULL)
  11464. X      free((voidp *)e);
  11465. X    err(ZE_MEM, "was trying a smart split");
  11466. X    return 0;                           /* only to make compiler happy */
  11467. X  }
  11468. X  memcpy((char *)e, (char *)a, n * sizeof(ulg));
  11469. X  for (t = i = 0; i < n; i++)
  11470. X    t += *(s[i] = e + i);
  11471. X  m = (extent)((t + c - 1) / c) - 1;    /* pre-decrement for loop */
  11472. X  qsort((char *)s, n, sizeof(ulg *), descmp);
  11473. X
  11474. X  /* Stuff bins until successful */
  11475. X  do {
  11476. X    /* Increment the number of bins, allocate and initialize bins */
  11477. X    if ((b = (ulg *)malloc(++m * sizeof(ulg))) == NULL)
  11478. X    {
  11479. X      free((voidp *)s);
  11480. X      free((voidp *)e);
  11481. X      err(ZE_MEM, "was trying a smart split");
  11482. X    }
  11483. X    b[0] = c - d;                       /* leave space in first bin */
  11484. X    for (j = 1; j < m; j++)
  11485. X      b[j] = c;
  11486. X
  11487. X    /* Fill the bins greedily */
  11488. X    for (i = 0; i < n; i++)
  11489. X    {
  11490. X      /* Find smallest bin that will hold item i (size s[i]) */
  11491. X      t = c + 1;
  11492. X      for (k = j = 0; j < m; j++)
  11493. X        if (*s[i] <= b[j] && b[j] < t)
  11494. X          t = b[k = j];
  11495. X
  11496. X      /* If no bins big enough for *s[i], try next m */
  11497. X      if (t == c + 1)
  11498. X        break;
  11499. X
  11500. X      /* Diminish that bin and save where it goes */
  11501. X      b[k] -= *s[i];
  11502. X      a[(int)((ulg huge *)(s[i]) - (ulg huge *)e)] = k;
  11503. X    }
  11504. X
  11505. X    /* Clean up */
  11506. X    free((voidp *)b);
  11507. X
  11508. X    /* Do until all items put in a bin */
  11509. X  } while (i < n);
  11510. X
  11511. X  /* Done--clean up and return the number of bins needed */
  11512. X  free((voidp *)s);
  11513. X  free((voidp *)e);
  11514. X  return m;
  11515. X}
  11516. X
  11517. X
  11518. Xvoid main(argc, argv)
  11519. Xint argc;               /* number of tokens in command line */
  11520. Xchar **argv;            /* command line tokens */
  11521. X/* Split a zip file into several zip files less than a specified size.  See
  11522. X   the command help in help() above. */
  11523. X{
  11524. X  ulg *a;               /* malloc'ed list of sizes, dest bins */
  11525. X  extent *b;            /* heads of bin linked lists (malloc'ed) */
  11526. X  ulg c;                /* bin capacity, start of central directory */
  11527. X  int d;                /* if true, just report the number of disks */
  11528. X  FILE *e;              /* input zip file */
  11529. X  FILE *f;              /* output index and zip files */
  11530. X  extent g;             /* number of bins from greedy(), entry to write */
  11531. X  int h;                /* how to split--true means simple split, counter */
  11532. X  ulg i;                /* size of index file or zero if none */
  11533. X  extent j;             /* steps through zip entries, bins */
  11534. X  int k;                /* next argument type */
  11535. X  ulg *p;               /* malloc'ed list of sizes, dest bins for greedy() */
  11536. X  char *q;              /* steps through option characters */
  11537. X  int r;                /* temporary variable, counter */
  11538. X  extent s;             /* number of bins needed */
  11539. X  ulg t;                /* total of sizes, end of central directory */
  11540. X  struct zlist far **w; /* malloc'ed table for zfiles linked list */
  11541. X  int x;                /* if true, make an index file */
  11542. X  struct zlist far *z;  /* steps through zfiles linked list */
  11543. X
  11544. X
  11545. X  /* If no args, show help */
  11546. X  if (argc == 1)
  11547. X  {
  11548. X    help();
  11549. X    exit(0);
  11550. X  }
  11551. X
  11552. X  init_upper();           /* build case map table */
  11553. X
  11554. X  /* Go through args */
  11555. X  signal(SIGINT, handler);
  11556. X  signal(SIGTERM, handler);
  11557. X  k = h = x = d = 0;
  11558. X  c = DEFSIZ;
  11559. X  for (r = 1; r < argc; r++)
  11560. X    if (*argv[r] == '-')
  11561. X      if (argv[r][1])
  11562. X        for (q = argv[r]+1; *q; q++)
  11563. X          switch(*q)
  11564. X          {
  11565. X            case 'b':   /* Specify path for output files */
  11566. X              if (k)
  11567. X                err(ZE_PARMS, "options are separate and precede zip file");
  11568. X              else
  11569. X                k = 1;          /* Next non-option is path */
  11570. X              break;
  11571. X            case 'h':   /* Show help */
  11572. X              help();  exit(0);
  11573. X            case 'i':   /* Make an index file */
  11574. X              x = 1;
  11575. X              break;
  11576. X            case 'l': case 'L':  /* Show copyright and disclaimer */
  11577. X              license();  exit(0);
  11578. X            case 'n':   /* Specify maximum size of resulting zip files */
  11579. X              if (k)
  11580. X                err(ZE_PARMS, "options are separate and precede zip file");
  11581. X              else
  11582. X                k = 2;          /* Next non-option is size */
  11583. X              break;
  11584. X            case 's':
  11585. X              h = 1;    /* Only try simple */
  11586. X              break;
  11587. X            case 't':   /* Just report number of disks */
  11588. X              d = 1;
  11589. X              break;
  11590. X            default:
  11591. X              err(ZE_PARMS, "unknown option");
  11592. X          }
  11593. X      else
  11594. X        err(ZE_PARMS, "zip file cannot be stdin");
  11595. X    else
  11596. X      if (k == 0)
  11597. X        if (zipfile == NULL)
  11598. X        {
  11599. X          if ((zipfile = ziptyp(argv[r])) == NULL)
  11600. X            err(ZE_MEM, "was processing arguments");
  11601. X        }
  11602. X        else
  11603. X          err(ZE_PARMS, "can only specify one zip file");
  11604. X      else if (k == 1)
  11605. X      {
  11606. X        tempath = argv[r];
  11607. X        k = 0;
  11608. X      }
  11609. X      else              /* k must be 2 */
  11610. X      {
  11611. X        if ((c = (ulg)atol(argv[r])) < 100)     /* 100 is smallest zip file */
  11612. X          err(ZE_PARMS, "invalid size given");
  11613. X        k = 0;
  11614. X      }
  11615. X  if (zipfile == NULL)
  11616. X    err(ZE_PARMS, "need to specify zip file");
  11617. X
  11618. X
  11619. X  /* Read zip file */
  11620. X  if ((r = readzipfile()) != ZE_OK)
  11621. X    err(r, zipfile);
  11622. X  if (zfiles == NULL)
  11623. X    err(ZE_NAME, zipfile);
  11624. X
  11625. X  /* Make a list of sizes and check against capacity.  Also compute the
  11626. X     size of the index file. */
  11627. X  c -= ENDHEAD + 4;                     /* subtract overhead/zipfile */
  11628. X  if ((a = (ulg *)malloc(zcount * sizeof(ulg))) == NULL ||
  11629. X      (w = (struct zlist far **)malloc(zcount * sizeof(struct zlist far *))) ==
  11630. X       NULL)
  11631. X  {
  11632. X    if (a != NULL)
  11633. X      free((voidp *)a);
  11634. X    err(ZE_MEM, "was computing split");
  11635. X    return;
  11636. X  }
  11637. X  i = t = 0;
  11638. X  for (j = 0, z = zfiles; j < zcount; j++, z = z->nxt)
  11639. X  {
  11640. X    w[j] = z;
  11641. X    if (x)
  11642. X      i += z->nam + 6 + NL;
  11643. X    t += a[j] = 8 + LOCHEAD + CENHEAD +
  11644. X           2 * (ulg)z->nam + 2 * (ulg)z->ext + z->com + z->siz;
  11645. X    if (a[j] > c)
  11646. X    {
  11647. X      free((voidp *)w);  free((voidp *)a);
  11648. X      err(ZE_BIG, z->zname);
  11649. X    }
  11650. X  }
  11651. X
  11652. X  /* Decide on split to use, report number of files */
  11653. X  if (h)
  11654. X    s = simple(a, zcount, c, i);
  11655. X  else
  11656. X  {
  11657. X    if ((p = (ulg *)malloc(zcount * sizeof(ulg))) == NULL)
  11658. X    {
  11659. X      free((voidp *)w);  free((voidp *)a);
  11660. X      err(ZE_MEM, "was computing split");
  11661. X    }
  11662. X    memcpy((char *)p, (char *)a, zcount * sizeof(ulg));
  11663. X    s = simple(a, zcount, c, i);
  11664. X    g = greedy(p, zcount, c, i);
  11665. X    if (s <= g)
  11666. X      free((voidp *)p);
  11667. X    else
  11668. X    {
  11669. X      free((voidp *)a);
  11670. X      a = p;
  11671. X      s = g;
  11672. X    }
  11673. X  }
  11674. X  printf("%d zip files w%s be made (%d%% efficiency)\n",
  11675. X         s, d ? "ould" : "ill", ((200 * ((t + c - 1)/c)) / s + 1) >> 1);
  11676. X  if (d)
  11677. X  {
  11678. X    free((voidp *)w);  free((voidp *)a);
  11679. X    free((voidp *)zipfile);
  11680. X    zipfile = NULL;
  11681. X    return;
  11682. X  }
  11683. X
  11684. X  /* Set up path for output files */
  11685. X  if ((path = malloc(tempath == NULL ? 13 : strlen(tempath) + 14)) == NULL)
  11686. X    err(ZE_MEM, "was making output file names");
  11687. X  if (tempath == NULL)
  11688. X     name = path;
  11689. X  else
  11690. X  {
  11691. X    strcpy(path, tempath);
  11692. X    if (path[0] && path[strlen(path) - 1] != '/')
  11693. X      strcat(path, "/");
  11694. X    name = path + strlen(path);
  11695. X  }
  11696. X
  11697. X  /* Write the index file */
  11698. X  if (x)
  11699. X  {
  11700. X    strcpy(name, INDEX);
  11701. X    printf("creating %s\n", path);
  11702. X    indexmade = 1;
  11703. X    if ((f = fopen(path, "w")) == NULL)
  11704. X    {
  11705. X      free((voidp *)w);  free((voidp *)a);
  11706. X      err(ZE_CREAT, path);
  11707. X    }
  11708. X    for (j = 0; j < zcount; j++)
  11709. X      fprintf(f, "%5ld %s\n", a[j] + 1, w[j]->zname);
  11710. X    if ((j = ferror(f)) != 0 || fclose(f))
  11711. X    {
  11712. X      if (j)
  11713. X        fclose(f);
  11714. X      free((voidp *)w);  free((voidp *)a);
  11715. X      err(ZE_WRITE, path);
  11716. X    }
  11717. X  }
  11718. X
  11719. X  /* Make linked lists of results */
  11720. X  if ((b = (extent *)malloc(s * sizeof(extent))) == NULL)
  11721. X  {
  11722. X    free((voidp *)w);  free((voidp *)a);
  11723. X    err(ZE_MEM, "was computing split");
  11724. X  }
  11725. X  for (j = 0; j < s; j++)
  11726. X    b[j] = (extent)-1;
  11727. X  j = zcount;
  11728. X  while (j--)
  11729. X  {
  11730. X    g = (extent)a[j];
  11731. X    a[j] = b[g];
  11732. X    b[g] = j;
  11733. X  }
  11734. X
  11735. X  /* Make a name template for the zip files that is eight or less characters
  11736. X     before the .zip, and that will not overwrite the original zip file. */
  11737. X  for (k = 1, j = s; j >= 10; j /= 10)
  11738. X    k++;
  11739. X  if (k > 7)
  11740. X  {
  11741. X    free((voidp *)b);  free((voidp *)w);  free((voidp *)a);
  11742. X    err(ZE_PARMS, "way too many zip files must be made");
  11743. X  }
  11744. X#ifdef VMS
  11745. X  if ((q = strrchr(zipfile, ']')) != NULL)
  11746. X#else /* !VMS */
  11747. X  if ((q = strrchr(zipfile, '/')) != NULL)
  11748. X#endif /* ?VMS */
  11749. X    q++;
  11750. X  else
  11751. X    q = zipfile;
  11752. X  r = 0;
  11753. X  while ((g = *q++) != 0 && g != '.' && r < 8 - k)
  11754. X    template[r++] = (char)g;
  11755. X  if (r == 0)
  11756. X    template[r++] = '_';
  11757. X  else if (g >= '0' && g <= '9')
  11758. X    template[r - 1] = (char)(template[r - 1] == '_' ? '-' : '_');
  11759. X  sprintf(template + r, "%%0%dd.zip", k);
  11760. X
  11761. X  /* Make the zip files from the linked lists of entry numbers */
  11762. X  if ((e = fopen(zipfile, FOPR)) == NULL)
  11763. X  {
  11764. X    free((voidp *)b);  free((voidp *)w);  free((voidp *)a);
  11765. X    err(ZE_NAME, zipfile);
  11766. X  }
  11767. X  free((voidp *)zipfile);
  11768. X  zipfile = NULL;
  11769. X  for (j = 0; j < s; j++)
  11770. X  {
  11771. X    sprintf(name, template, j + 1);
  11772. X    printf("creating %s\n", path);
  11773. X    zipsmade = j + 1;
  11774. X    if ((f = fopen(path, FOPW)) == NULL)
  11775. X    {
  11776. X      free((voidp *)b);  free((voidp *)w);  free((voidp *)a);
  11777. X      err(ZE_CREAT, path);
  11778. X    }
  11779. X    tempzn = 0;
  11780. X    for (g = b[j]; g != (extent)-1; g = (extent)a[g])
  11781. X    {
  11782. X      if (fseek(e, w[g]->off, SEEK_SET))
  11783. X      {
  11784. X        free((voidp *)b);  free((voidp *)w);  free((voidp *)a);
  11785. X        err(ferror(e) ? ZE_READ : ZE_EOF, zipfile);
  11786. X      }
  11787. X      if ((r = zipcopy(w[g], e, f)) != ZE_OK)
  11788. X      {
  11789. X        free((voidp *)b);  free((voidp *)w);  free((voidp *)a);
  11790. X        if (r == ZE_TEMP)
  11791. X          err(ZE_WRITE, path);
  11792. X        else
  11793. X          err(r, zipfile);
  11794. X      }
  11795. X    }
  11796. X    if ((c = ftell(f)) == -1L)
  11797. X    {
  11798. X      free((voidp *)b);  free((voidp *)w);  free((voidp *)a);
  11799. X      err(ZE_WRITE, path);
  11800. X    }
  11801. X    for (g = b[j], k = 0; g != (extent)-1; g = (extent)a[g], k++)
  11802. X      if ((r = putcentral(w[g], f)) != ZE_OK)
  11803. X      {
  11804. X        free((voidp *)b);  free((voidp *)w);  free((voidp *)a);
  11805. X        err(ZE_WRITE, path);
  11806. X      }
  11807. X    if ((t = ftell(f)) == -1L)
  11808. X    {
  11809. X      free((voidp *)b);  free((voidp *)w);  free((voidp *)a);
  11810. X      err(ZE_WRITE, path);
  11811. X    }
  11812. X    if ((r = putend(k, t - c, c, (extent)0, (char *)NULL, f)) != ZE_OK)
  11813. X    {
  11814. X      free((voidp *)b);  free((voidp *)w);  free((voidp *)a);
  11815. X      err(ZE_WRITE, path);
  11816. X    }
  11817. X    if (ferror(f) || fclose(f))
  11818. X    {
  11819. X      free((voidp *)b);  free((voidp *)w);  free((voidp *)a);
  11820. X      err(ZE_WRITE, path);
  11821. X    }
  11822. X  }
  11823. X  free((voidp *)b);  free((voidp *)w);  free((voidp *)a);
  11824. X  fclose(e);
  11825. X
  11826. X  /* Done! */
  11827. X  exit(0);
  11828. X}
  11829. END_OF_FILE
  11830.   if test 17114 -ne `wc -c <'zipsplit.c'`; then
  11831.     echo shar: \"'zipsplit.c'\" unpacked with wrong size!
  11832.   fi
  11833.   # end of 'zipsplit.c'
  11834. fi
  11835. echo shar: End of archive 7 \(of 11\).
  11836. cp /dev/null ark7isdone
  11837. MISSING=""
  11838. for I in 1 2 3 4 5 6 7 8 9 10 11 ; do
  11839.     if test ! -f ark${I}isdone ; then
  11840.     MISSING="${MISSING} ${I}"
  11841.     fi
  11842. done
  11843. if test "${MISSING}" = "" ; then
  11844.     echo You have unpacked all 11 archives.
  11845.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  11846. else
  11847.     echo You still must unpack the following archives:
  11848.     echo "        " ${MISSING}
  11849. fi
  11850. exit 0
  11851. exit 0 # Just in case...
  11852. Newsgroups: comp.sources.misc
  11853. From: zip-bugs@cs.ucla.edu (Info-ZIP group)
  11854. Subject:  v31i100:  zip19 - Info-ZIP portable Zip, version 1.9, Part08/11
  11855. Message-ID: <1992Aug23.064803.29419@sparky.imd.sterling.com>
  11856. X-Md4-Signature: 0d324eadec388c13d7566bdfa95fe008
  11857. Date: Sun, 23 Aug 1992 06:48:03 GMT
  11858. Approved: kent@sparky.imd.sterling.com
  11859.  
  11860. Submitted-by: zip-bugs@cs.ucla.edu (Info-ZIP group)
  11861. Posting-number: Volume 31, Issue 100
  11862. Archive-name: zip19/part08
  11863. Supersedes: zip: Volume 23, Issue 88-96
  11864. Environment: UNIX, VMS, OS/2, MS-DOS, MACINTOSH, WIN-NT, LINUX, MINIX, XOS, !AMIGA, ATARI, symlink, SGI, DEC, Cray, Convex, Amdahl, Sun, PC
  11865.  
  11866. #! /bin/sh
  11867. # This is a shell archive.  Remove anything before this line, then feed it
  11868. # into a shell via "sh file" or similar.  To overwrite existing files,
  11869. # type "sh file -c".
  11870. # The tool that generated this appeared in the comp.sources.unix newsgroup;
  11871. # send mail to comp-sources-unix@uunet.uu.net if you want that tool.
  11872. # Contents:  bits.c makecrc.c os2/makefile.os2.UU vms/VMSmunch.c
  11873. #   zipnote.c zipup.c
  11874. # Wrapped by kent@sparky on Sun Aug 23 01:00:46 1992
  11875. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  11876. echo If this archive is complete, you will see the following message:
  11877. echo '          "shar: End of archive 8 (of 11)."'
  11878. if test -f 'bits.c' -a "${1}" != "-c" ; then 
  11879.   echo shar: Will not clobber existing file \"'bits.c'\"
  11880. else
  11881.   echo shar: Extracting \"'bits.c'\" \(11292 characters\)
  11882.   sed "s/^X//" >'bits.c' <<'END_OF_FILE'
  11883. X/*
  11884. X
  11885. X Copyright (C) 1990-1992 Mark Adler, Richard B. Wales, Jean-loup Gailly,
  11886. X Kai Uwe Rommel and Igor Mandrichenko.
  11887. X Permission is granted to any individual or institution to use, copy, or
  11888. X redistribute this software so long as all of the original files are included
  11889. X unmodified, that it is not sold for profit, and that this copyright notice
  11890. X is retained.
  11891. X
  11892. X*/
  11893. X
  11894. X/*
  11895. X *  bits.c by Jean-loup Gailly and Kai Uwe Rommel.
  11896. X *
  11897. X *  This is a new version of im_bits.c originally written by Richard B. Wales
  11898. X *
  11899. X *  PURPOSE
  11900. X *
  11901. X *      Output variable-length bit strings. Compression can be done
  11902. X *      to a file or to memory.
  11903. X *
  11904. X *  DISCUSSION
  11905. X *
  11906. X *      The PKZIP "deflate" file format interprets compressed file data
  11907. X *      as a sequence of bits.  Multi-bit strings in the file may cross
  11908. X *      byte boundaries without restriction.
  11909. X *
  11910. X *      The first bit of each byte is the low-order bit.
  11911. X *
  11912. X *      The routines in this file allow a variable-length bit value to
  11913. X *      be output right-to-left (useful for literal values). For
  11914. X *      left-to-right output (useful for code strings from the tree routines),
  11915. X *      the bits must have been reversed first with bi_reverse().
  11916. X *
  11917. X *      For in-memory compression, the compressed bit stream goes directly
  11918. X *      into the requested output buffer. The input data is read in blocks
  11919. X *      by the mem_read() function.
  11920. X *
  11921. X *  INTERFACE
  11922. X *
  11923. X *      void bi_init (FILE *zipfile)
  11924. X *          Initialize the bit string routines.
  11925. X *
  11926. X *      void send_bits (int value, int length)
  11927. X *          Write out a bit string, taking the source bits right to
  11928. X *          left.
  11929. X *
  11930. X *      int bi_reverse (int value, int length)
  11931. X *          Reverse the bits of a bit string, taking the source bits left to
  11932. X *          right and emitting them right to left.
  11933. X *
  11934. X *      void bi_windup (void)
  11935. X *          Write out any remaining bits in an incomplete byte.
  11936. X *
  11937. X *      void copy_block(char far *buf, unsigned len, int header)
  11938. X *          Copy a stored block to the zip file, storing first the length and
  11939. X *          its one's complement if requested.
  11940. X *
  11941. X *      int seekable(void)
  11942. X *          Return true if the zip file can be seeked.
  11943. X *
  11944. X *      ulg memcompress (char *tgt, ulg tgtsize, char *src, ulg srcsize);
  11945. X *          Compress the source buffer src into the target buffer tgt.
  11946. X */
  11947. X
  11948. X#include "zip.h"
  11949. X
  11950. X/* ===========================================================================
  11951. X * Local data used by the "bit string" routines.
  11952. X */
  11953. X
  11954. Xlocal FILE *zfile; /* output zip file */
  11955. X
  11956. Xlocal unsigned short bi_buf;
  11957. X/* Output buffer. bits are inserted starting at the bottom (least significant
  11958. X * bits).
  11959. X */
  11960. X
  11961. X#define Buf_size (8 * 2*sizeof(char))
  11962. X/* Number of bits used within bi_buf. (bi_buf might be implemented on
  11963. X * more than 16 bits on some systems.)
  11964. X */
  11965. X
  11966. Xlocal int bi_valid;
  11967. X/* Number of valid bits in bi_buf.  All bits above the last valid bit
  11968. X * are always zero.
  11969. X */
  11970. X
  11971. Xchar file_outbuf[1024];
  11972. X/* Output buffer for compression to file */
  11973. X
  11974. Xlocal char *in_buf, *out_buf;
  11975. X/* Current input and output buffers. in_buf is used only for in-memory
  11976. X * compression.
  11977. X */
  11978. X
  11979. Xlocal ulg in_offset, out_offset;
  11980. X/* Current offset in input and output buffers. in_offset is used only for
  11981. X * in-memory compression.
  11982. X */
  11983. X
  11984. Xlocal ulg in_size, out_size;
  11985. X/* Size of current input and output buffers */
  11986. X
  11987. Xint (*read_buf) OF((char *buf, unsigned size)) = file_read;
  11988. X/* Current input function. Set to mem_read for in-memory compression */
  11989. X
  11990. X#ifdef DEBUG
  11991. Xulg bits_sent;   /* bit length of the compressed data */
  11992. X#endif
  11993. X
  11994. X/* Output a 16 bit value to the bit stream, lower (oldest) byte first */
  11995. X#define PUTSHORT(w) \
  11996. X{ if (out_offset < out_size-1) { \
  11997. X    out_buf[out_offset++] = (char) ((w) & 0xff); \
  11998. X    out_buf[out_offset++] = (char) ((ush)(w) >> 8); \
  11999. X  } else { \
  12000. X    flush_outbuf((w),2); \
  12001. X  } \
  12002. X}
  12003. X
  12004. X#define PUTBYTE(b) \
  12005. X{ if (out_offset < out_size) { \
  12006. X    out_buf[out_offset++] = (char) (b); \
  12007. X  } else { \
  12008. X    flush_outbuf((b),1); \
  12009. X  } \
  12010. X}
  12011. X
  12012. X
  12013. X/* ===========================================================================
  12014. X *  Prototypes for local functions
  12015. X */
  12016. Xlocal int  mem_read     OF((char *buf, unsigned size));
  12017. Xlocal void flush_outbuf OF((unsigned w, unsigned size));
  12018. X
  12019. X/* ===========================================================================
  12020. X * Initialize the bit string routines.
  12021. X */
  12022. Xvoid bi_init (zipfile)
  12023. X    FILE *zipfile;  /* output zip file, NULL for in-memory compression */
  12024. X{
  12025. X    zfile  = zipfile;
  12026. X    bi_buf = 0;
  12027. X    bi_valid = 0;
  12028. X#ifdef DEBUG
  12029. X    bits_sent = 0L;
  12030. X#endif
  12031. X
  12032. X    /* Set the defaults for file compression. They are set by memcompress
  12033. X     * for in-memory compression.
  12034. X     */
  12035. X    if (zfile != NULL) {
  12036. X        out_buf = file_outbuf;
  12037. X        out_size = sizeof(file_outbuf);
  12038. X        out_offset = 0;
  12039. X        read_buf  = file_read;
  12040. X    }
  12041. X}
  12042. X
  12043. X/* ===========================================================================
  12044. X * Send a value on a given number of bits.
  12045. X * IN assertion: length <= 16 and value fits in length bits.
  12046. X */
  12047. Xvoid send_bits(value, length)
  12048. X    int value;  /* value to send */
  12049. X    int length; /* number of bits */
  12050. X{
  12051. X#ifdef DEBUG
  12052. X    Tracevv((stderr," l %2d v %4x ", length, value));
  12053. X    Assert(length > 0 && length <= 15, "invalid length");
  12054. X    bits_sent += (ulg)length;
  12055. X#endif
  12056. X    /* If not enough room in bi_buf, use (valid) bits from bi_buf and
  12057. X     * (16 - bi_valid) bits from value, leaving (width - (16-bi_valid))
  12058. X     * unused bits in value.
  12059. X     */
  12060. X    if (bi_valid > (int)Buf_size - length) {
  12061. X        bi_buf |= (value << bi_valid);
  12062. X        PUTSHORT(bi_buf);
  12063. X        bi_buf = (ush)value >> (Buf_size - bi_valid);
  12064. X        bi_valid += length - Buf_size;
  12065. X    } else {
  12066. X        bi_buf |= value << bi_valid;
  12067. X        bi_valid += length;
  12068. X    }
  12069. X}
  12070. X
  12071. X/* ===========================================================================
  12072. X * Reverse the first len bits of a code, using straightforward code (a faster
  12073. X * method would use a table)
  12074. X * IN assertion: 1 <= len <= 15
  12075. X */
  12076. Xunsigned bi_reverse(code, len)
  12077. X    unsigned code; /* the value to invert */
  12078. X    int len;       /* its bit length */
  12079. X{
  12080. X    register unsigned res = 0;
  12081. X    do {
  12082. X        res |= code & 1;
  12083. X        code >>= 1, res <<= 1;
  12084. X    } while (--len > 0);
  12085. X    return res >> 1;
  12086. X}
  12087. X
  12088. X/* ===========================================================================
  12089. X * Flush the current output buffer.
  12090. X */
  12091. Xlocal void flush_outbuf(w, size)
  12092. X    unsigned w;    /* value to flush */
  12093. X    unsigned size; /* it size in bytes (0, 1 or 2) */
  12094. X{
  12095. X    if (zfile == NULL) {
  12096. X        error("output buffer too small for in-memory compression");
  12097. X    }
  12098. X    /* Encrypt and write the output buffer: */
  12099. X    if (out_offset != 0) {
  12100. X        zfwrite(out_buf, 1, (extent)out_offset, zfile);
  12101. X        if (ferror(zfile)) error ("write error on zip file");
  12102. X    }
  12103. X    out_offset = 0;
  12104. X    if (size == 2) {
  12105. X        PUTSHORT(w);
  12106. X    } else if (size == 1) {
  12107. X        out_buf[out_offset++] = (char) (w & 0xff);
  12108. X    }
  12109. X}
  12110. X
  12111. X/* ===========================================================================
  12112. X * Write out any remaining bits in an incomplete byte.
  12113. X */
  12114. Xvoid bi_windup()
  12115. X{
  12116. X    if (bi_valid > 8) {
  12117. X        PUTSHORT(bi_buf);
  12118. X    } else if (bi_valid > 0) {
  12119. X        PUTBYTE(bi_buf);
  12120. X    }
  12121. X    if (zfile != NULL) {
  12122. X        flush_outbuf(0, 0);
  12123. X    }
  12124. X    bi_buf = 0;
  12125. X    bi_valid = 0;
  12126. X#ifdef DEBUG
  12127. X    bits_sent = (bits_sent+7) & ~7;
  12128. X#endif
  12129. X}
  12130. X
  12131. X/* ===========================================================================
  12132. X * Copy a stored block to the zip file, storing first the length and its
  12133. X * one's complement if requested.
  12134. X */
  12135. Xvoid copy_block(buf, len, header)
  12136. X    char far *buf; /* the input data */
  12137. X    unsigned len;  /* its length */
  12138. X    int header;    /* true if block header must be written */
  12139. X{
  12140. X    bi_windup();              /* align on byte boundary */
  12141. X
  12142. X    if (header) {
  12143. X        PUTSHORT((ush)len);   
  12144. X        PUTSHORT((ush)~len);
  12145. X#ifdef DEBUG
  12146. X        bits_sent += 2*16;
  12147. X#endif
  12148. X    }
  12149. X    if (zfile) {
  12150. X        flush_outbuf(0, 0);
  12151. X        zfwrite(buf, 1, len, zfile);
  12152. X        if (ferror(zfile)) error ("write error on zip file");
  12153. X    } else if (out_offset + (ulg)len > out_size) {
  12154. X        error("output buffer too small for in-memory compression");
  12155. X    } else {
  12156. X        memcpy(out_buf + out_offset, buf, len);
  12157. X        out_offset += (ulg)len;
  12158. X    }
  12159. X#ifdef DEBUG
  12160. X    bits_sent += (ulg)len<<3;
  12161. X#endif
  12162. X}
  12163. X
  12164. X
  12165. X/* ===========================================================================
  12166. X * Return true if the zip file can be seeked. This is used to check if
  12167. X * the local header can be re-rewritten. This function always returns
  12168. X * true for in-memory compression.
  12169. X * IN assertion: the local header has already been written (ftell() > 0).
  12170. X */
  12171. Xint seekable()
  12172. X{
  12173. X    return (zfile == NULL ||
  12174. X            (fseek(zfile, -1L, SEEK_CUR) == 0 &&
  12175. X             fseek(zfile,  1L, SEEK_CUR) == 0));
  12176. X}    
  12177. X
  12178. X/* ===========================================================================
  12179. X * In-memory compression. This version can be used only if the entire input
  12180. X * fits in one memory buffer. The compression is then done in a single
  12181. X * call of memcompress(). (An extension to allow repeated calls would be
  12182. X * possible but is not needed here.)
  12183. X * The first two bytes of the compressed output are set to a short with the
  12184. X * method used (DEFLATE or STORE). The following four bytes contain the CRC.
  12185. X * The values are stored in little-endian order on all machines.
  12186. X * This function returns the byte size of the compressed output, including
  12187. X * the first six bytes (method and crc).
  12188. X */
  12189. X
  12190. Xulg memcompress(tgt, tgtsize, src, srcsize)
  12191. X    char *tgt, *src;       /* target and source buffers */
  12192. X    ulg tgtsize, srcsize;  /* target and source sizes */
  12193. X{
  12194. X    ush att      = (ush)UNKNOWN;
  12195. X    ush flags    = 0;
  12196. X    ulg crc      = 0;
  12197. X    int method   = DEFLATE;
  12198. X
  12199. X    if (tgtsize <= 6L) error("target buffer too small");
  12200. X
  12201. X    crc = updcrc((char *)NULL, 0);
  12202. X    crc = updcrc(src, (extent) srcsize);
  12203. X
  12204. X    read_buf  = mem_read;
  12205. X    in_buf    = src;
  12206. X    in_size   = srcsize;
  12207. X    in_offset = 0;
  12208. X
  12209. X    out_buf    = tgt;
  12210. X    out_size   = tgtsize;
  12211. X    out_offset = 2 + 4;
  12212. X
  12213. X    bi_init(NULL);
  12214. X    ct_init(&att, &method);
  12215. X    lm_init(level, &flags);
  12216. X    deflate();
  12217. X
  12218. X    /* For portability, force little-endian order on all machines: */
  12219. X    tgt[0] = (char)(method & 0xff);
  12220. X    tgt[1] = (char)((method >> 8) & 0xff);
  12221. X    tgt[2] = (char)(crc & 0xff);
  12222. X    tgt[3] = (char)((crc >> 8) & 0xff);
  12223. X    tgt[4] = (char)((crc >> 16) & 0xff);
  12224. X    tgt[5] = (char)((crc >> 24) & 0xff);
  12225. X
  12226. X    return out_offset;
  12227. X}
  12228. X
  12229. X/* ===========================================================================
  12230. X * In-memory read function. As opposed to file_read(), this function
  12231. X * does not perform end-of-line translation, and does not update the
  12232. X * crc and input size.
  12233. X *    Note that the size of the entire input buffer is an unsigned long,
  12234. X * but the size used in mem_read() is only an unsigned int. This makes a
  12235. X * difference on 16 bit machines. mem_read() may be called several
  12236. X * times for an in-memory compression.
  12237. X */
  12238. Xlocal int mem_read(buf, size)
  12239. X     char *buf;
  12240. X     unsigned size; 
  12241. X{
  12242. X    if (in_offset < in_size) {
  12243. X        ulg block_size = in_size - in_offset;
  12244. X        if (block_size > (ulg)size) block_size = (ulg)size;
  12245. X        memcpy(buf, in_buf + in_offset, (unsigned)block_size);
  12246. X        in_offset += block_size;
  12247. X        return (int)block_size;
  12248. X    } else {
  12249. X        return 0; /* end of input */
  12250. X    }
  12251. X}
  12252. END_OF_FILE
  12253.   if test 11292 -ne `wc -c <'bits.c'`; then
  12254.     echo shar: \"'bits.c'\" unpacked with wrong size!
  12255.   fi
  12256.   # end of 'bits.c'
  12257. fi
  12258. if test -f 'makecrc.c' -a "${1}" != "-c" ; then 
  12259.   echo shar: Will not clobber existing file \"'makecrc.c'\"
  12260. else
  12261.   echo shar: Extracting \"'makecrc.c'\" \(2388 characters\)
  12262.   sed "s/^X//" >'makecrc.c' <<'END_OF_FILE'
  12263. X/* Not copyrighted 1990 Mark Adler */
  12264. X
  12265. X#include <stdio.h>
  12266. X
  12267. Xmain()
  12268. X/*
  12269. X  Generate a table for a byte-wise 32-bit CRC calculation on the polynomial:
  12270. X  x^32+x^26+x^23+x^22+x^16+x^12+x^11+x^10+x^8+x^7+x^5+x^4+x^2+x+1.
  12271. X
  12272. X  Polynomials over GF(2) are represented in binary, one bit per coefficient,
  12273. X  with the lowest powers in the most significant bit.  Then adding polynomials
  12274. X  is just exclusive-or, and multiplying a polynomial by x is a right shift by
  12275. X  one.  If we call the above polynomial p, and represent a byte as the
  12276. X  polynomial q, also with the lowest power in the most significant bit (so the
  12277. X  byte 0xb1 is the polynomial x^7+x^3+x+1), then the CRC is (q*x^32) mod p,
  12278. X  where a mod b means the remainder after dividing a by b.
  12279. X
  12280. X  This calculation is done using the shift-register method of multiplying and
  12281. X  taking the remainder.  The register is initialized to zero, and for each
  12282. X  incoming bit, x^32 is added mod p to the register if the bit is a one (where
  12283. X  x^32 mod p is p+x^32 = x^26+...+1), and the register is multiplied mod p by
  12284. X  x (which is shifting right by one and adding x^32 mod p if the bit shifted
  12285. X  out is a one).  We start with the highest power (least significant bit) of
  12286. X  q and repeat for all eight bits of q.
  12287. X
  12288. X  The table is simply the CRC of all possible eight bit values.  This is all
  12289. X  the information needed to generate CRC's on data a byte at a time for all
  12290. X  combinations of CRC register values and incoming bytes.  The table is
  12291. X  written to stdout as 256 long hexadecimal values in C language format.
  12292. X*/
  12293. X{
  12294. X  unsigned long c;      /* crc shift register */
  12295. X  unsigned long e;      /* polynomial exclusive-or pattern */
  12296. X  int i;                /* counter for all possible eight bit values */
  12297. X  int k;                /* byte being shifted into crc apparatus */
  12298. X
  12299. X  /* terms of polynomial defining this crc (except x^32): */
  12300. X  static int p[] = {0,1,2,4,5,7,8,10,11,12,16,22,23,26};
  12301. X
  12302. X  /* Make exclusive-or pattern from polynomial */
  12303. X  e = 0;
  12304. X  for (i = 0; i < sizeof(p)/sizeof(int); i++)
  12305. X    e |= 1L << (31 - p[i]);
  12306. X
  12307. X  /* Compute and print table of CRC's, five per line */
  12308. X  printf("  0x00000000L");
  12309. X  for (i = 1; i < 256; i++)
  12310. X  {
  12311. X    c = 0;
  12312. X    for (k = i | 256; k != 1; k >>= 1)
  12313. X    {
  12314. X      c = c & 1 ? (c >> 1) ^ e : c >> 1;
  12315. X      if (k & 1)
  12316. X        c ^= e;
  12317. X    }
  12318. X    printf(i % 5 ? ", 0x%08lxL" : ",\n  0x%08lxL", c);
  12319. X  }
  12320. X  putchar('\n');
  12321. X  return 0;
  12322. X}
  12323. END_OF_FILE
  12324.   if test 2388 -ne `wc -c <'makecrc.c'`; then
  12325.     echo shar: \"'makecrc.c'\" unpacked with wrong size!
  12326.   fi
  12327.   # end of 'makecrc.c'
  12328. fi
  12329. if test -f 'os2/makefile.os2.UU' -a "${1}" != "-c" ; then 
  12330.   echo shar: Will not clobber existing file \"'os2/makefile.os2.UU'\"
  12331. else
  12332.   echo shar: Extracting \"'os2/makefile.os2.UU'\" \(8519 characters\)
  12333.   sed "s/^X//" >'os2/makefile.os2.UU' <<'END_OF_FILE'
  12334. Xbegin 666 os2/makefile.os2
  12335. XM(R!-86ME9FEL92!F;W(@6FEP+"!::7!#;&]A:RP@6FEP3F]T92!A;F0@6FEP
  12336. XM4W!L:70-"@T*(R!3=7!P;W)T960@36%K92!U=&EL:71I97,Z#0HC("T@36EC
  12337. XM<F]S;V9T+TE"32!N;6%K90T*(R M(&1M86ME(#,N." H<&%R86QL96P@;6%K
  12338. XM92P@=7-E("U0-"!I9B!Y;W4@:&%V92!T:&4@;65M;W)Y*2P-"B,@("!I;B!T
  12339. XM:&4@97AE(&9I;&4@=&%R9V5T<RP@>6]U('=I;&P@:&%V92!T;R!A9&0@<W!A
  12340. XM8V5S(&)E9F]R92 D0"!F;W(@9V-C#0HC("T@3D]4('=A=&-O;2!M86ME("AB
  12341. XM<F%I;B!D96%D+"!A<'!A<F5N=&QY(&1O97-N)W0@:VYO=R!L:6YE<R!C;VYT
  12342. XM)V0@=VET:"!<*0T*(R M($Y/5"!'3E4@;6%K92 H8G5G9WDL(&EN8V]M<&%T
  12343. XM:6)L92D-"@T*(R!3=7!P;W)T960@0R!#;VUP:6QE<G,Z#0HC("T@36EC<F]S
  12344. XM;V9T($,@-BXP,"!U;F1E<B!/4R\R(#$N>" H,38M8FET*0T*(R M($=.52!G
  12345. XM8V,@*&5M>"!K:70I('5N9&5R($]3+S(@,BXP#0HC("T@24)-($,@4V5T+S(@
  12346. XM=6YD97(@3U,O,B R+C @(" @(" @("T@9&]E<R!N;W0@>65T('=O<FL@=VET
  12347. XM:"!!4TT@8V]D90T*(R M(%=A=&-O;2!#+S,X-B Y+C @=6YD97(@3U,O,B R
  12348. XM+C @(" M(&1O97,@;F]T('EE="!W;W)K('=I=&@@05--(&-O9&4-"@T*(R!3
  12349. XM=7!P;W)T960@07-S96UB;&5R<SH-"B,@+2!-:6-R;W-O9G0@34%332 V+C P
  12350. XM('=I=&@@35,@0RP@24)-($,L(%=A=&-O;2!##0HC("T@36EC<F]S;V9T($U!
  12351. XM4TT@-2YX>"!W:71H($U3($,L(&EF('5N8V]M;65N=" B;6%S;2(@;&EN92!N
  12352. XM96%R(&QI;F4@,34P#0HC("T@1TY5(&%S('=I=&@@1TY5(&=C8PT*#0HC(%1O
  12353. XM('5S92P@96YT97(@(FYM86ME+V1M86ME("UF(&UA:V5F:6QE+F]S,B(@*'1H
  12354. XM:7,@;6%K969I;&4@9&5P96YD<R!O;B!I=',-"B,@;F%M92!B96EN9R B;6%K
  12355. XM969I;&4N;W,R(BDN#0H-"B,@061D("U$3D]?05--('1O($-&3$%'4R!A;F0@
  12356. XM<F5M;W9E(&UA=&-H+F]B:B!F<F]M($]"2D\@:68@>6]U(&1O#0HC(&YO="!H
  12357. XM879E(&UA<VT@;W(@;6PN#0HC($%D9" M1$193E]!3$Q/0R!T;R!!4T9,04=3
  12358. XM(&EF('EO=2!H879E(&1E9FEN960@:70@:6X@=&%I;&]R+F@@;W(@0T9,04=3
  12359. XM#0H-"B,@3F]T97,@;VX@,38M8FET("A-:6-R;W-O9G0@0R V+C P*2!C;VUP
  12360. XM:6QA=&EO;CH-"@T*(R @(%1H92!R97-U;'1I;F<@<')O9W)A;7,@8V%N(&)E
  12361. XM('5S960@=6YD97(@3U,O,B!P<F]T96-T960@;6]D92!O;FQY+@T*(R @($$@
  12362. XM;&%R9V5R('-T86-K(&AA<R!T;R!B92!U<V5D(&9O<B!/4R\R(&)E8V%U<V4@
  12363. XM<WES=&5M(&-A;&QS#0HC(" @=7-E(&UO<F4@<W1A8VL@=&AA;B!U;F1E<B!$
  12364. XM3U,L(#AK(&ES(')E8V]M;65N9&5D(&)Y($UI8W)O<V]F="X-"B,@("!.;W1E
  12365. XM('1H870@7U]35$1#7U\@:&%S('1O(&)E(&1E9FEN960@97AP;&EC:71L>2!W
  12366. XM:71H($,@-BXP,"!W:&5N("U:90T*(R @(&ES(&=I=F5N+"!B96-A=7-E($UI
  12367. XM8W)O<V]F="!D:7-A8FQE<R!?7U-41$-?7R!W:&5N('1H96ER(&5X=&5N<VEO
  12368. XM;G,-"B,@("!A<F4@96YA8FQE9"X@5&AI<R!I<R!D:69F97)E;G0@9G)O;2!T
  12369. XM:&4@0R U+C$P(&)E:&%V:6]U<BX-"@T*(R!.;W1E<R!O;B S,BUB:70@*$E"
  12370. XM32!#(%-E="\R+"!7871C;VT@0R!O<B!'3E4@9V-C*2!C;VUP:6QA=&EO;CH-
  12371. XM"@T*(R @(%1H92!R97-U;'1I;F<@<')O9W)A;7,@8V%N(&)E('5S960@=6YD
  12372. XM97(@3U,O,B!P<F]T96-T960-"B,@("!M;V1E(&]F($]3+S(@,BXP(&]N;'DL
  12373. XM(&YO="!U;F1E<B Q+G@@86YD(&YO="!U;F1E<B!$3U,N#0HC(" @270@;6%K
  12374. XM97,@;F\@9&EF9F5R96YC92!I9B!?7U-41$-?7R!I<R!D969I;F5D(&]R(&YO
  12375. XM="X-"B,@("!7871C;VT@0R!A;F0@24)-($,@4V5T+S(@=V]R:R!W:71H($19
  12376. XM3E]!3$Q/0R!O;FQY+"!B96-A=7-E(&]F#0HC(" @0V]M<&EL97(@8G5G<RX-
  12377. XM"@T*0U)94%1//0T*0TQ/04L]#0I#4D9,04<]#0HC(" J*BH@1F]R(&5N8W)Y
  12378. XM<'1I;VX@=F5R<VEO;BP@<F5M;W9E('1H92 C(&%T('1H92!F<F]N="!O9B!N
  12379. XM97AT(#,@;&EN97,@*BHJ#0HC0U)94%1//6-R>7!T)"A/0DHI#0HC0TQ/04L]
  12380. XM>FEP8VQO86LN97AE#0HC0U)&3$%'/2U$0U)94%0-"@T*9&5F875L=#H-"@E 
  12381. XM96-H;R!%;G1E<B B)"A-04M%*2 M9B!M86ME9FEL92YO<S(@;7-C(@T*"4!E
  12382. XM8VAO(" @(&]R("(D*$U!2T4I("UF(&UA:V5F:6QE+F]S,B!I8FTB#0H)0&5C
  12383. XM:&\@(" @;W(@(B0H34%+12D@+68@;6%K969I;&4N;W,R('=A=&-O;2(-"@E 
  12384. XM96-H;R @("!O<B B)"A-04M%*2 M9B!M86ME9FEL92YO<S(@9V-C(@T*#0IM
  12385. XM<V-D;W,Z#0H))"A-04M%*2 M9B!M86ME9FEL92YO<S(@>FEP<R!<#0H)0T,]
  12386. XM(F-L("UN;VQO9V\@+4%#("U/86EC=" M1W,B(%P-"@E#1DQ!1U,](BU7,R M
  12387. XM6F5P("0H0U)&3$%'*2 D*$90*2(@7 T*"4%3/2)M;" M;F]L;V=O(B!<#0H)
  12388. XM05-&3$%'4STB+5IM("U#<"(@7 T*"4Q$1DQ!1U,](B0H1E I("U,<B M1B Q
  12389. XM,# P("U&92(@7 T*(" @(" @("!,1$9,04=3,CTB+6QI;FL@+VYO92(@7 T*
  12390. XM(" @(" @("!/550](BU&;R(@7 T*(" @(" @("!/0DH](BYO8FHB(%P-"@E/
  12391. XM0DI!/6UA=&-H+F]B:B!<#0H@(" @(" @($]"2D\](B(-"@T*;7-C.@T*"20H
  12392. XM34%+12D@+68@;6%K969I;&4N;W,R('II<',@7 T*"4-#/2)C;" M;F]L;V=O
  12393. XM("U!0R M3V-E9VET("U'<R(@7 T*"4-&3$%'4STB+5<Q("U:97 @+4H@+4<R
  12394. XM("0H0U)&3$%'*2 M1%]?4U1$0U]?("U$3U,R("0H1E I(B!<#0H)05,](FUL
  12395. XM("UN;VQO9V\B(%P-"@E!4T9,04=3/2(M6FT@+4-P(B!<#0H)3$1&3$%'4STB
  12396. XM)"A&4"D@+4QP("U&(#(P,# @+49E(B!<#0H@(" @(" @($Q$1DQ!1U,R/2(M
  12397. XM;&EN:R O;F]E(B!<#0H@(" @(" @($]55#TB+49O(B!<#0H@(" @(" @($]"
  12398. XM2CTB+F]B:B(@7 T*"4]"2D$];6%T8V@N;V)J(%P-"B @(" @(" @1$5&/2)Z
  12399. XM:7 N9&5F(@T*#0II8FTZ#0H))"A-04M%*2 M9B!M86ME9FEL92YO<S(@>FEP
  12400. XM<R!<#0H)0T,](FEC8R M42 M3R M1W,B(%P-"@E#1DQ!1U,](BU3;2 M4W Q
  12401. XM("0H0U)&3$%'*2 M1$]3,B M1$193E]!3$Q/0R M1$Y/7T%332(@7 T*"4Y&
  12402. XM3$%'4STB+4\M(B!<#0H)05,](FUL("UN;VQO9V\B(%P-"@E!4T9,04=3/2(M
  12403. XM6FT@+4-P(B!<#0H)3$1&3$%'4STB+4(O4U0Z,3,Q,#<R("U&92(@7 T*(" @
  12404. XM(" @("!,1$9,04=3,CTB(B!<#0H@(" @(" @($]55#TB+49O(B!<#0H@(" @
  12405. XM(" @($]"2CTB+F]B:B(@7 T*"4]"2D$](B(@7 T*(" @(" @("!$148](GII
  12406. XM<"YD968B#0H-"G=A=&-O;3H-"@DD*$U!2T4I("UF(&UA:V5F:6QE+F]S,B!Z
  12407. XM:7!S(%P-"@E#0STB=V-L,S@V("UZ<2 M3W@@+7,B(%P-"@E#1DQ!1U,](BU:
  12408. XM<#$@)"A#4D9,04<I("U$3U,R("U$1%E.7T%,3$]#("U$3D]?05--(B!<#0H)
  12409. XM05,](FUL("UN;VQO9V\B(%P-"@E!4T9,04=3/2(M6FT@+4-P(B!<#0H)3$1&
  12410. XM3$%'4STB+6LQ,S$P-S(@+7@@+49E/2(@7 T*(" @(" @("!,1$9,04=3,CTB
  12411. XM(B!<#0H@(" @(" @($]55#TB+49O(B!<#0H@(" @(" @($]"2CTB+F]B:B(@
  12412. XM7 T*"4]"2D$](B(-"@T*9V-C.@T*"20H34%+12D@+68@;6%K969I;&4N;W,R
  12413. XM('II<',@7 T*"4-#/2)G8V,@+4\@+7,B(%P-"@E#1DQ!1U,](B0H0U)&3$%'
  12414. XM*2 M1$]3,B(@7 T*"4%3/2)G8V,B(%P-"@E!4T9,04=3/2(M575N:7@B(%P-
  12415. XM"@E,1$9,04=3/2(M;R B(%P-"B @(" @(" @3$1&3$%'4S(](BUL;W,R(B!<
  12416. XM#0H@(" @(" @($]55#TB+6\B(%P-"B @(" @(" @3T)*/2(N;R(@7 T*"4]"
  12417. XM2D$](FUA=&-H+F\B#0H-"D]"2D\@/2 @;W,R>FEP#0H-"D]"2EH@/2 @>FEP
  12418. XM)"A/0DHI('II<&9I;&4D*$]"2BD@>FEP=7 D*$]"2BD@9FEL96EO)"A/0DHI
  12419. XM('5T:6PD*$]"2BD@7 T*(" @(" @("!G;&]B86QS)"A/0DHI(&1E9FQA=&4D
  12420. XM*$]"2BD@=')E97,D*$]"2BD@8FET<R0H3T)**2 D*$-265!43RD@7 T*"20H
  12421. XM3T)*3RDD*$]"2BD-"@T*3T)*52 ]("!Z:7!F:6QE7R0H3T)**2!Z:7!U<%\D
  12422. XM*$]"2BD@9FEL96EO7R0H3T)**2!U=&EL7R0H3T)**2!<#0H)9VQO8F%L<R0H
  12423. XM3T)**2 D*$]"2D\I7R0H3T)**0T*#0I/0DI.(#T@('II<&YO=&4D*$]"2BD@
  12424. XM)"A/0DI5*0T*3T)*0R ]("!Z:7!C;&]A:R0H3T)**2!C<GEP=%\D*$]"2BD@
  12425. XM)"A/0DI5*0T*3T)*4R ]("!Z:7!S<&QI="0H3T)**2 D*$]"2E4I#0H-"BYC
  12426. XM)"A/0DHI.@T*"20H0T,I("UC("0H0T9,04=3*2 D/ T*#0IZ:7!S.@EZ:7 N
  12427. XM97AE('II<&YO=&4N97AE('II<'-P;&ET+F5X92 D*$-,3T%+*0T*#0IZ:7 D
  12428. XM*$]"2BDZ"7II<"YC('II<"YH('II<&5R<BYH('1A:6QO<BYH(')E=FES:6]N
  12429. XM+F@-"GII<&9I;&4D*$]"2BDZ"7II<&9I;&4N8R!Z:7 N:"!Z:7!E<G(N:"!T
  12430. XM86EL;W(N: T*>FEP=7 D*$]"2BDZ"7II<'5P+F,@>FEP+F@@>FEP97)R+F@@
  12431. XM=&%I;&]R+F@@<F5V:7-I;VXN:"!O<S)Z:7 N: T*9FEL96EO)"A/0DHI.@EF
  12432. XM:6QE:6\N8R!Z:7 N:"!Z:7!E<G(N:"!T86EL;W(N:"!O<S)Z:7 N: T*=71I
  12433. XM;"0H3T)**3H)=71I;"YC('II<"YH('II<&5R<BYH('1A:6QO<BYH(&]S,GII
  12434. XM<"YH#0IG;&]B86QS)"A/0DHI.@EG;&]B86QS+F,@>FEP+F@@>FEP97)R+F@@
  12435. XM=&%I;&]R+F@-"F1E9FQA=&4D*$]"2BDZ"61E9FQA=&4N8R!Z:7 N:"!Z:7!E
  12436. XM<G(N:"!T86EL;W(N: T*=')E97,D*$]"2BDZ"71R965S+F,@>FEP+F@@>FEP
  12437. XM97)R+F@@=&%I;&]R+F@-"@DD*$-#*2 M8R D*$-&3$%'4RD@)"A.1DQ!1U,I
  12438. XM("0J+F,-"F)I=',D*$]"2BDZ"6)I=',N8R!Z:7 N:"!Z:7!E<G(N:"!T86EL
  12439. XM;W(N: T*8W)Y<'0D*$]"2BDZ"6-R>7!T+F,@>FEP+F@@>FEP97)R+F@@=&%I
  12440. XM;&]R+F@-"F]S,GII<"0H3T)**3H);W,R>FEP+F,@;W,R>FEP+F@-"@T*;6%T
  12441. XM8V@N;V)J.@EM871C:"YA<VT-"@DD*$%3*2 M8R D*$%31DQ!1U,I("0J+F%S
  12442. XM;0T*(R!U<V4@=&AE(&9O;&QO=VEN9R!F;W(@34%332 U+C P(&EN<W1E860@
  12443. XM;V8@-BXP, T*(PEM87-M("UM;" M=" D*BYA<VT[#0H-"FUA=&-H,S(N;V)J
  12444. XM.@EM871C:#,R+F%S;0T*"20H05,I("UC("0H05-&3$%'4RD@)"HN87-M#0H-
  12445. XM"FUA=&-H+F\Z"6UA=&-H+G,-"B,@;F]T92!T:&4@=7!P97)C87-E(%,@9F]R
  12446. XM(&=C8R!T;R!R=6X@;6%T8V@N<R!T:')O=6=H(&-P<"$-"@DD*$%3*2 M8R D
  12447. XM*$%31DQ!1U,I("0J+E,-"@T*>FEP8VQO86LD*$]"2BDZ"7II<&-L;V%K+F,@
  12448. XM>FEP+F@@>FEP97)R+F@@=&%I;&]R+F@@<F5V:7-I;VXN: T*>FEP;F]T920H
  12449. XM3T)**3H)>FEP;F]T92YC('II<"YH('II<&5R<BYH('1A:6QO<BYH(')E=FES
  12450. XM:6]N+F@-"GII<'-P;&ET)"A/0DHI.B!Z:7!S<&QI="YC('II<"YH('II<&5R
  12451. XM<BYH('1A:6QO<BYH(')E=FES:6]N+F@-"@T*>FEP9FEL95\D*$]"2BDZ"7II
  12452. XM<&9I;&4N8R!Z:7 N:"!Z:7!E<G(N:"!T86EL;W(N: T*"20H0T,I("UC("0H
  12453. XM0T9,04=3*2 M1%5424P@)"A/550I)$ @>FEP9FEL92YC#0H-"GII<'5P7R0H
  12454. XM3T)**3H)>FEP=7 N8R!Z:7 N:"!Z:7!E<G(N:"!T86EL;W(N: T*"20H0T,I
  12455. XM("UC("0H0T9,04=3*2 M1%5424P@)"A/550I)$ @>FEP=7 N8PT*#0IF:6QE
  12456. XM:6]?)"A/0DHI.@EF:6QE:6\N8R!Z:7 N:"!Z:7!E<G(N:"!T86EL;W(N: T*
  12457. XM"20H0T,I("UC("0H0T9,04=3*2 M1%5424P@)"A/550I)$ @9FEL96EO+F,-
  12458. XM"@T*=71I;%\D*$]"2BDZ"75T:6PN8R!Z:7 N:"!Z:7!E<G(N:"!T86EL;W(N
  12459. XM:"!O<S)Z:7 N: T*"20H0T,I("UC("0H0T9,04=3*2 M1%5424P@)"A/550I
  12460. XM)$ @=71I;"YC#0H-"F-R>7!T7R0H3T)**3H)8W)Y<'0N8R!Z:7 N:"!Z:7!E
  12461. XM<G(N:"!T86EL;W(N: T*"20H0T,I("UC("0H0T9,04=3*2 M1%5424P@)"A/
  12462. XM550I)$ @8W)Y<'0N8PT*#0IO<S)Z:7!?)"A/0DHI.B!O<S)Z:7 N8R!O<S)Z
  12463. XM:7 N: T*"20H0T,I("UC("0H0T9,04=3*2 M1%5424P@)"A/550I)$ @;W,R
  12464. XM>FEP+F,-"@T*>FEP+F5X93H@)"A/0DI:*2 D*$]"2DDI("0H3T)*02D@)"A$
  12465. XM148I#0H))"A#0RD@)"A,1$9,04=3*21 ("0H1$5&*2 D*$]"2EHI("0H3T)*
  12466. XM22D@)"A/0DI!*2 D*$Q$1DQ!1U,R*0T*#0IZ:7!C;&]A:RYE>&4Z("0H3T)*
  12467. XM0RD@)"A$148I#0H))"A#0RD@)"A,1$9,04=3*21 ("0H1$5&*2 D*$]"2D,I
  12468. XM("0H3$1&3$%'4S(I#0H-"GII<&YO=&4N97AE.B D*$]"2DXI("0H1$5&*0T*
  12469. XM"20H0T,I("0H3$1&3$%'4RDD0" D*$1%1BD@)"A/0DI.*2 D*$Q$1DQ!1U,R
  12470. XM*0T*#0IZ:7!S<&QI="YE>&4Z("0H3T)*4RD@)"A$148I#0H))"A#0RD@)"A,
  12471. XF1$9,04=3*21 ("0H1$5&*2 D*$]"2E,I("0H3$1&3$%'4S(I#0I#
  12472. Xend
  12473. END_OF_FILE
  12474.  if test 8519 -ne `wc -c <'os2/makefile.os2.UU'`; then
  12475.     echo shar: \"'os2/makefile.os2.UU'\" unpacked with wrong size!
  12476.   else
  12477.     echo shar: Uudecoding \"'os2/makefile.os2'\" \(6158 characters\)
  12478.     cat os2/makefile.os2.UU | uudecode
  12479.     if test 6158 -ne `wc -c <'os2/makefile.os2'`; then
  12480.       echo shar: \"'os2/makefile.os2'\" uudecoded with wrong size!
  12481.     else
  12482.       rm os2/makefile.os2.UU
  12483.     fi
  12484.   fi
  12485.   # end of 'os2/makefile.os2.UU'
  12486. fi
  12487. if test -f 'vms/VMSmunch.c' -a "${1}" != "-c" ; then 
  12488.   echo shar: Will not clobber existing file \"'vms/VMSmunch.c'\"
  12489. else
  12490.   echo shar: Extracting \"'vms/VMSmunch.c'\" \(11629 characters\)
  12491.   sed "s/^X//" >'vms/VMSmunch.c' <<'END_OF_FILE'
  12492. X/*---------------------------------------------------------------------------
  12493. X
  12494. X  VMSmunch.c                    version 1.2                     28 Apr 1992
  12495. X
  12496. X  This routine is a blatant and unrepentent appropriation of all the nasty
  12497. X  and difficult-to-do and complicated VMS shenanigans which Joe Meadows has
  12498. X  so magnificently captured in his FILE utility.  Not only that, it's even
  12499. X  allowed! (see below).  But let it be clear at the outset that Joe did all
  12500. X  the work; yea, verily, he is truly a godlike unit.
  12501. X
  12502. X  The appropriations and modifications herein were performed primarily by
  12503. X  him known as "Cave Newt," although the Info-ZIP working group probably had
  12504. X  their fingers in it somewhere along the line.  The idea is to put the raw
  12505. X  power of Joe's original routine at the disposal of various routines used
  12506. X  by UnZip (and Zip, possibly), not least among them the utime() function.
  12507. X  Read on for details...
  12508. X
  12509. X  ---------------------------------------------------------------------------
  12510. X
  12511. X  Usage (i.e., "interface," in geek-speak):
  12512. X
  12513. X     int VMSmunch( char *filename, int action, char *ptr );
  12514. X
  12515. X     filename   the name of the file on which to be operated, obviously
  12516. X     action     an integer which specifies what action to take
  12517. X     ptr        pointer to any extra item which may be needed (else NULL)
  12518. X
  12519. X  The possible values for the action argument are as follows:
  12520. X
  12521. X     GET_TIMES      get the creation and revision dates of filename; ptr
  12522. X                    must point to an empty VMStimbuf struct, as defined below
  12523. X                    (with room for at least 24 characters, including term.)
  12524. X     SET_TIMES      set the creation and revision dates of filename (utime
  12525. X                    option); ptr must point to a valid VMStimbuf struct,
  12526. X                    as defined below
  12527. X     GET_RTYPE      get the record type of filename; ptr must point to an
  12528. X                    integer which, on return, is set to the type (as defined
  12529. X                    in VMSmunch.h:  FAT$C_* defines)
  12530. X     CHANGE_RTYPE   change the record type to that specified by the integer
  12531. X                    to which ptr points; save the old record type (later
  12532. X                    saves overwrite earlier ones)
  12533. X     RESTORE_RTYPE  restore the record type to the previously saved value;
  12534. X                    or, if none, set it to "fixed-length, 512-byte" record
  12535. X                    format (ptr not used)
  12536. X
  12537. X  ---------------------------------------------------------------------------
  12538. X
  12539. X  Comments from FILE.C, a utility to modify file characteristics:
  12540. X
  12541. X     Written by Joe Meadows Jr, at the Fred Hutchinson Cancer Research Center
  12542. X     BITNET: JOE@FHCRCVAX
  12543. X     PHONE: (206) 467-4970
  12544. X
  12545. X     There are no restrictions on this code, you may sell it, include it 
  12546. X     with any commercial package, or feed it to a whale.. However, I would 
  12547. X     appreciate it if you kept this comment in the source code so that anyone
  12548. X     receiving this code knows who to contact in case of problems. Note that 
  12549. X     I do not demand this condition..
  12550. X
  12551. X  ---------------------------------------------------------------------------*/
  12552. X
  12553. X
  12554. X
  12555. X
  12556. X/*****************************/
  12557. X/*  Includes, Defines, etc.  */
  12558. X/*****************************/
  12559. X
  12560. X#include <descrip.h>
  12561. X#include <rms.h>
  12562. X#include <stdio.h>
  12563. X#include <iodef.h>
  12564. X#include <atrdef.h>   /* this gets created with the c3.0 compiler */
  12565. X#include <fibdef.h>   /* this gets created with the c3.0 compiler */
  12566. X
  12567. X#include "VMSmunch.h"  /* GET/SET_TIMES, RTYPE, fatdef.h, etc. */
  12568. X
  12569. X#define RTYPE     fat$r_rtype_overlay.fat$r_rtype_bits
  12570. X#define RATTRIB   fat$r_rattrib_overlay.fat$r_rattrib_bits
  12571. X
  12572. Xstatic void asctim();
  12573. Xstatic void bintim();
  12574. X
  12575. Xstruct VMStimbuf {      /* VMSmunch */
  12576. X    char *actime;       /* VMS revision date, ASCII format */
  12577. X    char *modtime;      /* VMS creation date, ASCII format */
  12578. X};
  12579. X
  12580. X/* from <ssdef.h> */
  12581. X#ifndef SS$_NORMAL
  12582. X#  define SS$_NORMAL    1
  12583. X#  define SS$_BADPARAM  20
  12584. X#endif
  12585. X
  12586. X
  12587. X
  12588. X
  12589. X
  12590. X/*************************/
  12591. X/*  Function VMSmunch()  */
  12592. X/*************************/
  12593. X
  12594. Xint VMSmunch( filename, action, ptr )
  12595. X    char  *filename, *ptr;
  12596. X    int   action;
  12597. X{
  12598. X
  12599. X    /* original file.c variables */
  12600. X
  12601. X    static struct FAB Fab;
  12602. X    static struct NAM Nam;
  12603. X    static struct fibdef Fib; /* short fib */
  12604. X
  12605. X    static struct dsc$descriptor FibDesc =
  12606. X      {sizeof(Fib),DSC$K_DTYPE_Z,DSC$K_CLASS_S,&Fib};
  12607. X    static struct dsc$descriptor_s DevDesc =
  12608. X      {0,DSC$K_DTYPE_T,DSC$K_CLASS_S,&Nam.nam$t_dvi[1]};
  12609. X    static struct fatdef Fat;
  12610. X    static union {
  12611. X      struct fchdef fch;
  12612. X      long int dummy;
  12613. X    } uchar;
  12614. X    static struct fjndef jnl;
  12615. X    static long int Cdate[2],Rdate[2],Edate[2],Bdate[2];
  12616. X    static short int revisions;
  12617. X    static unsigned long uic;
  12618. X    static union {
  12619. X      unsigned short int value;
  12620. X      struct {
  12621. X        unsigned system : 4;
  12622. X        unsigned owner : 4;
  12623. X        unsigned group : 4;
  12624. X        unsigned world : 4;
  12625. X      } bits;
  12626. X    } prot;
  12627. X
  12628. X    static struct atrdef Atr[] = {
  12629. X      {sizeof(Fat),ATR$C_RECATTR,&Fat},        /* record attributes */
  12630. X      {sizeof(uchar),ATR$C_UCHAR,&uchar},      /* File characteristics */
  12631. X      {sizeof(Cdate),ATR$C_CREDATE,&Cdate[0]}, /* Creation date */
  12632. X      {sizeof(Rdate),ATR$C_REVDATE,&Rdate[0]}, /* Revision date */
  12633. X      {sizeof(Edate),ATR$C_EXPDATE,&Edate[0]}, /* Expiration date */
  12634. X      {sizeof(Bdate),ATR$C_BAKDATE,&Bdate[0]}, /* Backup date */
  12635. X      {sizeof(revisions),ATR$C_ASCDATES,&revisions}, /* number of revisions */
  12636. X      {sizeof(prot),ATR$C_FPRO,&prot},         /* file protection  */
  12637. X      {sizeof(uic),ATR$C_UIC,&uic},            /* file owner */
  12638. X      {sizeof(jnl),ATR$C_JOURNAL,&jnl},        /* journal flags */
  12639. X      {0,0,0}
  12640. X    } ;
  12641. X
  12642. X    static char EName[NAM$C_MAXRSS];
  12643. X    static char RName[NAM$C_MAXRSS];
  12644. X    static struct dsc$descriptor_s FileName =
  12645. X      {0,DSC$K_DTYPE_T,DSC$K_CLASS_S,0};
  12646. X    static struct dsc$descriptor_s string = {0,DSC$K_DTYPE_T,DSC$K_CLASS_S,0};
  12647. X    static short int DevChan;
  12648. X    static short int iosb[4];
  12649. X
  12650. X    static long int i,status;
  12651. X/*  static char *retval;  */
  12652. X
  12653. X
  12654. X    /* new VMSmunch variables */
  12655. X
  12656. X    static int  old_rtype=FAT$C_FIXED;   /* storage for record type */
  12657. X
  12658. X
  12659. X
  12660. X/*---------------------------------------------------------------------------
  12661. X    Initialize attribute blocks, parse filename, resolve any wildcards, and
  12662. X    get the file info.
  12663. X  ---------------------------------------------------------------------------*/
  12664. X
  12665. X    /* initialize RMS structures, we need a NAM to retrieve the FID */
  12666. X    Fab = cc$rms_fab;
  12667. X    Fab.fab$l_fna = filename;
  12668. X    Fab.fab$b_fns = strlen(filename);
  12669. X    Fab.fab$l_nam = &Nam; /* FAB has an associated NAM */
  12670. X    Nam = cc$rms_nam;
  12671. X    Nam.nam$l_esa = &EName; /* expanded filename */
  12672. X    Nam.nam$b_ess = sizeof(EName);
  12673. X    Nam.nam$l_rsa = &RName; /* resultant filename */
  12674. X    Nam.nam$b_rss = sizeof(RName);
  12675. X
  12676. X    /* do $PARSE and $SEARCH here */
  12677. X    status = sys$parse(&Fab);
  12678. X    if (!(status & 1)) return(status);
  12679. X
  12680. X    /* search for the first file.. If none signal error */
  12681. X    status = sys$search(&Fab);
  12682. X    if (!(status & 1)) return(status);
  12683. X
  12684. X    while (status & 1) {
  12685. X        /* initialize Device name length, note that this points into the NAM
  12686. X           to get the device name filled in by the $PARSE, $SEARCH services */
  12687. X        DevDesc.dsc$w_length = Nam.nam$t_dvi[0];
  12688. X
  12689. X        status = sys$assign(&DevDesc,&DevChan,0,0);
  12690. X        if (!(status & 1)) return(status);
  12691. X
  12692. X        FileName.dsc$a_pointer = Nam.nam$l_name;
  12693. X        FileName.dsc$w_length = Nam.nam$b_name+Nam.nam$b_type+Nam.nam$b_ver;
  12694. X
  12695. X        /* Initialize the FIB */
  12696. X        for (i=0;i<3;i++)
  12697. X            Fib.fib$r_fid_overlay.fib$w_fid[i]=Nam.nam$w_fid[i];
  12698. X        for (i=0;i<3;i++)
  12699. X            Fib.fib$r_did_overlay.fib$w_did[i]=Nam.nam$w_did[i];
  12700. X
  12701. X        /* Use the IO$_ACCESS function to return info about the file */
  12702. X        /* Note, used this way, the file is not opened, and the expiration */
  12703. X        /* and revision dates are not modified */
  12704. X        status = sys$qiow(0,DevChan,IO$_ACCESS,&iosb,0,0,
  12705. X                          &FibDesc,&FileName,0,0,&Atr,0);
  12706. X        if (!(status & 1)) return(status);
  12707. X        status = iosb[0];
  12708. X        if (!(status & 1)) return(status);
  12709. X
  12710. X    /*-----------------------------------------------------------------------
  12711. X        We have the current information from the file:  now see what user
  12712. X        wants done with it.
  12713. X      -----------------------------------------------------------------------*/
  12714. X
  12715. X        switch (action) {
  12716. X
  12717. X          case GET_TIMES:
  12718. X              asctim(((struct VMStimbuf *)ptr)->modtime, Cdate);
  12719. X              asctim(((struct VMStimbuf *)ptr)->actime, Rdate);
  12720. X              break;
  12721. X
  12722. X          case SET_TIMES:
  12723. X              bintim(((struct VMStimbuf *)ptr)->modtime, Cdate);
  12724. X              bintim(((struct VMStimbuf *)ptr)->actime, Rdate);
  12725. X              break;
  12726. X
  12727. X          case GET_RTYPE:   /* non-modifying */
  12728. X              *(int *)ptr = Fat.RTYPE.fat$v_rtype;
  12729. X              return RMS$_NORMAL;     /* return to user */
  12730. X              break;
  12731. X
  12732. X          case CHANGE_RTYPE:
  12733. X              old_rtype = Fat.RTYPE.fat$v_rtype;         /* save current one */
  12734. X              if ((*(int *)ptr < FAT$C_UNDEFINED) || 
  12735. X                  (*(int *)ptr > FAT$C_STREAMCR))
  12736. X                  Fat.RTYPE.fat$v_rtype = FAT$C_STREAMLF;  /* Unix I/O happy */
  12737. X              else
  12738. X                  Fat.RTYPE.fat$v_rtype = *(int *)ptr;
  12739. X              break;
  12740. X
  12741. X          case RESTORE_RTYPE:
  12742. X              Fat.RTYPE.fat$v_rtype = old_rtype;
  12743. X              break;
  12744. X
  12745. X          default:
  12746. X              return SS$_BADPARAM;   /* anything better? */
  12747. X        }
  12748. X
  12749. X    /*-----------------------------------------------------------------------
  12750. X        Go back and write modified data to the file header.
  12751. X      -----------------------------------------------------------------------*/
  12752. X
  12753. X        /* note, part of the FIB was cleared by earlier QIOW, so reset it */
  12754. X        Fib.fib$r_acctl_overlay.fib$l_acctl = FIB$M_NORECORD;
  12755. X        for (i=0;i<3;i++)
  12756. X            Fib.fib$r_fid_overlay.fib$w_fid[i]=Nam.nam$w_fid[i];
  12757. X        for (i=0;i<3;i++)
  12758. X            Fib.fib$r_did_overlay.fib$w_did[i]=Nam.nam$w_did[i];
  12759. X
  12760. X        /* Use the IO$_MODIFY function to change info about the file */
  12761. X        /* Note, used this way, the file is not opened, however this would */
  12762. X        /* normally cause the expiration and revision dates to be modified. */
  12763. X        /* Using FIB$M_NORECORD prohibits this from happening. */
  12764. X        status = sys$qiow(0,DevChan,IO$_MODIFY,&iosb,0,0,
  12765. X                          &FibDesc,&FileName,0,0,&Atr,0);
  12766. X        if (!(status & 1)) return(status);
  12767. X
  12768. X        status = iosb[0];
  12769. X        if (!(status & 1)) return(status);
  12770. X
  12771. X        status = sys$dassgn(DevChan);
  12772. X        if (!(status & 1)) return(status);
  12773. X
  12774. X        /* look for next file, if none, no big deal.. */
  12775. X        status = sys$search(&Fab);
  12776. X    }
  12777. X} /* end function VMSmunch() */
  12778. X
  12779. X
  12780. X
  12781. X
  12782. X
  12783. X/***********************/
  12784. X/*  Function bintim()  */
  12785. X/***********************/
  12786. X
  12787. Xvoid asctim(time,binval)   /* convert 64-bit binval to string, put in time */
  12788. X    char *time;
  12789. X    long int binval[2];
  12790. X{
  12791. X    static struct dsc$descriptor date_str={23,DSC$K_DTYPE_T,DSC$K_CLASS_S,0};
  12792. X      /* dsc$w_length, dsc$b_dtype, dsc$b_class, dsc$a_pointer */
  12793. X    date_str.dsc$a_pointer = time;
  12794. X    sys$asctim(0, &date_str, binval, 0);
  12795. X    time[23] = '\0';
  12796. X}
  12797. X
  12798. X
  12799. X
  12800. X
  12801. X
  12802. X/***********************/
  12803. X/*  Function bintim()  */
  12804. X/***********************/
  12805. X
  12806. Xvoid bintim(time,binval)   /* convert time string to 64 bits, put in binval */
  12807. X    char *time;
  12808. X    long int binval[2];
  12809. X{
  12810. X    static struct dsc$descriptor date_str={0,DSC$K_DTYPE_T,DSC$K_CLASS_S,0};
  12811. X
  12812. X    date_str.dsc$w_length = strlen(time);
  12813. X    date_str.dsc$a_pointer = time;
  12814. X    sys$bintim(&date_str, binval);
  12815. X}
  12816. END_OF_FILE
  12817.   if test 11629 -ne `wc -c <'vms/VMSmunch.c'`; then
  12818.     echo shar: \"'vms/VMSmunch.c'\" unpacked with wrong size!
  12819.   fi
  12820.   # end of 'vms/VMSmunch.c'
  12821. fi
  12822. if test -f 'zipnote.c' -a "${1}" != "-c" ; then 
  12823.   echo shar: Will not clobber existing file \"'zipnote.c'\"
  12824. else
  12825.   echo shar: Extracting \"'zipnote.c'\" \(9993 characters\)
  12826.   sed "s/^X//" >'zipnote.c' <<'END_OF_FILE'
  12827. X/*
  12828. X
  12829. X Copyright (C) 1990-1992 Mark Adler, Richard B. Wales, Jean-loup Gailly,
  12830. X Kai Uwe Rommel and Igor Mandrichenko.
  12831. X Permission is granted to any individual or institution to use, copy, or
  12832. X redistribute this software so long as all of the original files are included
  12833. X unmodified, that it is not sold for profit, and that this copyright notice
  12834. X is retained.
  12835. X
  12836. X*/
  12837. X
  12838. X/*
  12839. X *  zipnote.c by Mark Adler.
  12840. X */
  12841. X
  12842. X#define UTIL
  12843. X#include "revision.h"
  12844. X#include "zip.h"
  12845. X#include <signal.h>
  12846. X
  12847. X
  12848. X/* Character to mark zip entry names in the comment file */
  12849. X#define MARK '@'
  12850. X
  12851. X/* Temporary zip file name and file pointer */
  12852. Xlocal char *tempzip;
  12853. Xlocal FILE *tempzf;
  12854. X
  12855. X
  12856. X/* Local functions */
  12857. X#ifdef PROTO
  12858. X   local void handler(int);
  12859. X   local void license(void);
  12860. X   local void help(void);
  12861. X   local void putclean(char *, int);
  12862. X   local int catalloc(char * far *, char *);
  12863. X   void main(int, char **);
  12864. X#endif /* PROTO */
  12865. X
  12866. X
  12867. X
  12868. Xvoid err(c, h)
  12869. Xint c;                  /* error code from the ZE_ class */
  12870. Xchar *h;                /* message about how it happened */
  12871. X/* Issue a message for the error, clean up files and memory, and exit. */
  12872. X{
  12873. X  if (PERR(c))
  12874. X    perror("zipnote error");
  12875. X  fprintf(stderr, "zipnote error: %s (%s)\n", errors[c-1], h);
  12876. X  if (tempzf != NULL)
  12877. X    fclose(tempzf);
  12878. X  if (tempzip != NULL)
  12879. X  {
  12880. X    destroy(tempzip);
  12881. X    free((voidp *)tempzip);
  12882. X  }
  12883. X  if (zipfile != NULL)
  12884. X    free((voidp *)zipfile);
  12885. X#ifdef VMS
  12886. X  exit(0);
  12887. X#else /* !VMS */
  12888. X  exit(c);
  12889. X#endif /* ?VMS */
  12890. X}
  12891. X
  12892. X
  12893. Xlocal void handler(s)
  12894. Xint s;                  /* signal number (ignored) */
  12895. X/* Upon getting a user interrupt, abort cleanly using err(). */
  12896. X{
  12897. X#ifndef MSDOS
  12898. X  putc('\n', stderr);
  12899. X#endif /* !MSDOS */
  12900. X  err(ZE_ABORT, "aborting");
  12901. X  s++;                                  /* keep some compilers happy */
  12902. X}
  12903. X
  12904. X
  12905. Xvoid warn(a, b)
  12906. Xchar *a, *b;            /* message strings juxtaposed in output */
  12907. X/* Print a warning message to stderr and return. */
  12908. X{
  12909. X  fprintf(stderr, "zipnote warning: %s%s\n", a, b);
  12910. X}
  12911. X
  12912. X
  12913. Xlocal void license()
  12914. X/* Print license information to stdout. */
  12915. X{
  12916. X  extent i;             /* counter for copyright array */
  12917. X
  12918. X  for (i = 0; i < sizeof(copyright)/sizeof(char *); i++) {
  12919. X    printf(copyright[i], "zipnote");
  12920. X    putchar('\n');
  12921. X  }
  12922. X  for (i = 0; i < sizeof(disclaimer)/sizeof(char *); i++)
  12923. X    puts(disclaimer[i]);
  12924. X}
  12925. X
  12926. X
  12927. Xlocal void help()
  12928. X/* Print help (along with license info) to stdout. */
  12929. X{
  12930. X  extent i;             /* counter for help array */
  12931. X
  12932. X  /* help array */
  12933. X  static char *text[] = {
  12934. X"",
  12935. X"ZipNote %d.%d (%s)",
  12936. X"Usage:  zipnote [-w] [-b path] zipfile",
  12937. X"  the default action is to write the comments in zipfile to stdout",
  12938. X"  -w   write the zipfile comments from stdin",
  12939. X"  -b   use \"path\" for the temporary zip file",
  12940. X"  -h   show this help               -L   show software license",
  12941. X"",
  12942. X"Example:",
  12943. X#ifdef VMS
  12944. X"     define/user sys$output foo.tmp",
  12945. X"     zipnote foo.zip",
  12946. X"     edit foo.tmp",
  12947. X"     ... then you edit the comments, save, and exit ...",
  12948. X"     define/user sys$input foo.tmp",
  12949. X"     zipnote -w foo.zip"
  12950. X#else /* !VMS */
  12951. X"     zipnote foo.zip > foo.tmp",
  12952. X"     ed foo.tmp",
  12953. X"     ... then you edit the comments, save, and exit ...",
  12954. X"     zipnote -w foo.zip < foo.tmp"
  12955. X#endif /* ?VMS */
  12956. X  };
  12957. X
  12958. X  for (i = 0; i < sizeof(copyright)/sizeof(char *); i++) {
  12959. X    printf(copyright[i], "zipnote");
  12960. X    putchar('\n');
  12961. X  }
  12962. X  for (i = 0; i < sizeof(text)/sizeof(char *); i++)
  12963. X  {
  12964. X    printf(text[i], REVISION / 10, REVISION % 10, REVDATE);
  12965. X    putchar('\n');
  12966. X  }
  12967. X}
  12968. X
  12969. X
  12970. Xlocal void putclean(s, n)
  12971. Xchar *s;                /* string to write to stdout */
  12972. Xint n;                  /* length of string */
  12973. X/* Write the string s to stdout, filtering out control characters that are
  12974. X   not tab or newline (mainly to remove carriage returns), and prefix MARK's
  12975. X   and backslashes with a backslash.  Also, terminate with a newline if
  12976. X   needed. */
  12977. X{
  12978. X  int c;                /* next character in string */
  12979. X  int e;                /* last character written */
  12980. X
  12981. X  e = '\n';                     /* if empty, write nothing */
  12982. X  while (n--)
  12983. X  {
  12984. X    c = *(uch *)s++;
  12985. X    if (c == MARK || c == '\\')
  12986. X      putchar('\\');
  12987. X    if (c >= ' ' || c == '\t' || c == '\n')
  12988. X      putchar(e = c);
  12989. X  }
  12990. X  if (e != '\n')
  12991. X    putchar('\n');
  12992. X}
  12993. X
  12994. X
  12995. Xlocal int catalloc(a, s)
  12996. Xchar * far *a;          /* pointer to a pointer to a malloc'ed string */
  12997. Xchar *s;                /* string to concatenate on a */
  12998. X/* Concatentate the string s to the malloc'ed string pointed to by a.
  12999. X   Preprocess s by removing backslash escape characters. */
  13000. X{
  13001. X  char *p;              /* temporary pointer */
  13002. X  char *q;              /* temporary pointer */
  13003. X
  13004. X  for (p = q = s; *q; *p++ = *q++)
  13005. X    if (*q == '\\' && *(q+1))
  13006. X      q++;
  13007. X  *p = 0;
  13008. X  if ((p = malloc(strlen(*a) + strlen(s) + 3)) == NULL)
  13009. X    return ZE_MEM;
  13010. X  strcat(strcat(strcpy(p, *a), **a ? "\r\n" : ""), s);
  13011. X  free((voidp *)*a);
  13012. X  *a = p;
  13013. X  return ZE_OK;
  13014. X}
  13015. X
  13016. X
  13017. Xvoid main(argc, argv)
  13018. Xint argc;               /* number of tokens in command line */
  13019. Xchar **argv;            /* command line tokens */
  13020. X/* Write the comments in the zipfile to stdout, or read them from stdin. */
  13021. X{
  13022. X  char a[FNMAX+1];      /* input line buffer */
  13023. X  ulg c;                /* start of central directory */
  13024. X  int k;                /* next argument type */
  13025. X  char *q;              /* steps through option arguments */
  13026. X  int r;                /* arg counter, temporary variable */
  13027. X  ulg s;                /* length of central directory */
  13028. X  int t;                /* attributes of zip file */
  13029. X  int w;                /* true if updating zip file from stdin */
  13030. X  FILE *x, *y;          /* input and output zip files */
  13031. X  struct zlist far *z;  /* steps through zfiles linked list */
  13032. X
  13033. X
  13034. X  /* If no args, show help */
  13035. X  if (argc == 1)
  13036. X  {
  13037. X    help();
  13038. X    exit(0);
  13039. X  }
  13040. X
  13041. X  init_upper();           /* build case map table */
  13042. X
  13043. X  /* Go through args */
  13044. X  zipfile = tempzip = NULL;
  13045. X  tempzf = NULL;
  13046. X  signal(SIGINT, handler);
  13047. X  signal(SIGTERM, handler);
  13048. X  k = w = 0;
  13049. X  for (r = 1; r < argc; r++)
  13050. X    if (*argv[r] == '-')
  13051. X      if (argv[r][1])
  13052. X        for (q = argv[r]+1; *q; q++)
  13053. X          switch(*q)
  13054. X          {
  13055. X            case 'b':   /* Specify path for temporary file */
  13056. X              if (k)
  13057. X                err(ZE_PARMS, "use -b before zip file name");
  13058. X              else
  13059. X                k = 1;          /* Next non-option is path */
  13060. X              break;
  13061. X            case 'h':   /* Show help */
  13062. X              help();  exit(0);
  13063. X            case 'l':  case 'L':  /* Show copyright and disclaimer */
  13064. X              license();  exit(0);
  13065. X            case 'w':
  13066. X              w = 1;  break;
  13067. X            default:
  13068. X              err(ZE_PARMS, "unknown option");
  13069. X          }
  13070. X      else
  13071. X        err(ZE_PARMS, "zip file cannot be stdin");
  13072. X    else
  13073. X      if (k == 0)
  13074. X        if (zipfile == NULL)
  13075. X        {
  13076. X          if ((zipfile = ziptyp(argv[r])) == NULL)
  13077. X            err(ZE_MEM, "was processing arguments");
  13078. X        }
  13079. X        else
  13080. X          err(ZE_PARMS, "can only specify one zip file");
  13081. X      else
  13082. X      {
  13083. X        tempath = argv[r];
  13084. X        k = 0;
  13085. X      }
  13086. X  if (zipfile == NULL)
  13087. X    err(ZE_PARMS, "need to specify zip file");
  13088. X
  13089. X  /* Read zip file */
  13090. X  if ((r = readzipfile()) != ZE_OK)
  13091. X    err(r, zipfile);
  13092. X  if (zfiles == NULL)
  13093. X    err(ZE_NAME, zipfile);
  13094. X
  13095. X  /* Put comments to stdout, if not -w */
  13096. X  if (!w)
  13097. X  {
  13098. X    for (z = zfiles; z != NULL; z = z->nxt)
  13099. X    {
  13100. X      printf("%c %s\n", MARK, z->zname);
  13101. X      putclean(z->comment, z->com);
  13102. X      putchar(MARK);  putchar('\n');
  13103. X    }
  13104. X    putchar(MARK);  putchar('\n');
  13105. X    putclean(zcomment, zcomlen);
  13106. X    exit(ZE_OK);
  13107. X  }
  13108. X
  13109. X  /* If updating comments, make sure zip file is writeable */
  13110. X  if ((x = fopen(zipfile, "a")) == NULL)
  13111. X    err(ZE_CREAT, zipfile);
  13112. X  fclose(x);
  13113. X  t = getfileattr(zipfile);
  13114. X
  13115. X  /* Process stdin, replacing comments */
  13116. X  for (z = zfiles; z != NULL; z = z->nxt)
  13117. X  {
  13118. X    if (gets(a) == NULL || a[0] != MARK || a[1] != ' ' ||
  13119. X        strcmp(a + 2, z->zname))
  13120. X      err(ZE_NOTE, "missing entry name");
  13121. X    if (z->com)
  13122. X      free((voidp *)z->comment);
  13123. X    z->comment = malloc(1);  *(z->comment) = 0;
  13124. X    while (gets(a) != NULL && *a != MARK)
  13125. X      if ((r = catalloc(&(z->comment), a)) != ZE_OK)
  13126. X        err(r, "was building new comments");
  13127. X    if (a[1])
  13128. X      err(ZE_NOTE, "missing comment end line");
  13129. X    z->com = strlen(z->comment);
  13130. X  }
  13131. X  if (gets(a) == NULL || a[0] != MARK || a[1])
  13132. X    err(ZE_NOTE, "missing zip file comment marker line");
  13133. X  zcomment = malloc(1);  *zcomment = 0;
  13134. X  while (gets(a) != NULL)
  13135. X    if ((r = catalloc(&zcomment, a)) != ZE_OK)
  13136. X      err(r, "was building new comments");
  13137. X  zcomlen = strlen(zcomment);
  13138. X
  13139. X  /* Open output zip file for writing */
  13140. X  if ((tempzf = y = fopen(tempzip = tempname(zipfile), FOPW)) == NULL)
  13141. X    err(ZE_TEMP, tempzip);
  13142. X
  13143. X  /* Open input zip file again, copy preamble if any */
  13144. X  if ((x = fopen(zipfile, FOPR)) == NULL)
  13145. X    err(ZE_NAME, zipfile);
  13146. X  if (zipbeg && (r = fcopy(x, y, zipbeg)) != ZE_OK)
  13147. X    err(r, r == ZE_TEMP ? tempzip : zipfile);
  13148. X
  13149. X  /* Go through local entries, copying them over as is */
  13150. X  for (z = zfiles; z != NULL; z = z->nxt)
  13151. X    if ((r = zipcopy(z, x, y)) != ZE_OK)
  13152. X      err(r, "was copying an entry");
  13153. X  fclose(x);
  13154. X
  13155. X  /* Write central directory and end of central directory with new comments */
  13156. X  if ((c = ftell(y)) == -1L)    /* get start of central */
  13157. X    err(ZE_TEMP, tempzip);
  13158. X  for (z = zfiles; z != NULL; z = z->nxt)
  13159. X    if ((r = putcentral(z, y)) != ZE_OK)
  13160. X      err(r, tempzip);
  13161. X  if ((s = ftell(y)) == -1L)    /* get end of central */
  13162. X    err(ZE_TEMP, tempzip);
  13163. X  s -= c;                       /* compute length of central */
  13164. X  if ((r = putend((int)zcount, s, c, zcomlen, zcomment, y)) != ZE_OK)
  13165. X    err(r, tempzip);
  13166. X  tempzf = NULL;
  13167. X  if (fclose(y))
  13168. X    err(ZE_TEMP, tempzip);
  13169. X  if ((r = replace(zipfile, tempzip)) != ZE_OK)
  13170. X  {
  13171. X    warn("new zip file left as: ", tempzip);
  13172. X    free((voidp *)tempzip);
  13173. X    tempzip = NULL;
  13174. X    err(r, "was replacing the original zip file");
  13175. X  }
  13176. X  free((voidp *)tempzip);
  13177. X  tempzip = NULL;
  13178. X  setfileattr(zipfile, t);
  13179. X  free((voidp *)zipfile);
  13180. X  zipfile = NULL;
  13181. X
  13182. X  /* Done! */
  13183. X  exit(ZE_OK);
  13184. X}
  13185. END_OF_FILE
  13186.   if test 9993 -ne `wc -c <'zipnote.c'`; then
  13187.     echo shar: \"'zipnote.c'\" unpacked with wrong size!
  13188.   fi
  13189.   # end of 'zipnote.c'
  13190. fi
  13191. if test -f 'zipup.c' -a "${1}" != "-c" ; then 
  13192.   echo shar: Will not clobber existing file \"'zipup.c'\"
  13193. else
  13194.   echo shar: Extracting \"'zipup.c'\" \(12100 characters\)
  13195.   sed "s/^X//" >'zipup.c' <<'END_OF_FILE'
  13196. X/*
  13197. X
  13198. X Copyright (C) 1990-1992 Mark Adler, Richard B. Wales, Jean-loup Gailly,
  13199. X Kai Uwe Rommel and Igor Mandrichenko.
  13200. X Permission is granted to any individual or institution to use, copy, or
  13201. X redistribute this software so long as all of the original files are included
  13202. X unmodified, that it is not sold for profit, and that this copyright notice
  13203. X is retained.
  13204. X
  13205. X*/
  13206. X
  13207. X/*
  13208. X *  zipup.c by Mark Adler. Includes modifications by Jean-loup Gailly.
  13209. X */
  13210. X
  13211. X#define NOCPYRT         /* this is not a main module */
  13212. X#include <ctype.h>
  13213. X#include "zip.h"
  13214. X#include "revision.h"
  13215. X#ifdef OS2
  13216. X#  include "os2zip.h"
  13217. X#endif
  13218. X
  13219. X/* Use the raw functions for MSDOS and Unix to save on buffer space.
  13220. X   They're not used for VMS since it doesn't work (raw is weird on VMS).
  13221. X   (This sort of stuff belongs in fileio.c, but oh well.) */
  13222. X#ifdef VMS
  13223. X#  define fhow "r"
  13224. X#  define fbad NULL
  13225. X   typedef void *ftype;
  13226. X#  define zopen(n,p)   (vms_native?vms_open(n)    :(ftype)fopen((n),(p)))
  13227. X#  define zread(f,b,n) (vms_native?vms_read(f,b,n):fread((b),1,(n),(FILE*)(f)))
  13228. X#  define zclose(f)    (vms_native?vms_close(f)   :fclose((FILE*)(f)))
  13229. X#  define zerr(f)      (vms_native?vms_error(f)   :ferror((FILE*)(f)))
  13230. X#  define zstdin stdin
  13231. X   ftype vms_open OF((char *));
  13232. X   int vms_read OF((ftype, char *, int));
  13233. X   int vms_close OF((ftype));
  13234. X   int vms_error OF((ftype));
  13235. X#else /* !VMS */
  13236. X#  if defined(MSDOS) && !defined(ATARI_ST)
  13237. X#    include <io.h>
  13238. X#    include <fcntl.h>
  13239. X#    define fhow (O_RDONLY|O_BINARY)
  13240. X#  else /* !MSDOS */
  13241. X     int open OF((char *, int));
  13242. X     int read OF((int, char *, int));
  13243. X     int close OF((int));
  13244. X     int lseek OF((int, long, int));
  13245. X#    define fhow 0
  13246. X#  endif /* ?MSDOS */
  13247. X   typedef int ftype;
  13248. X#  define fbad (-1)
  13249. X#  define zopen(n,p) open(n,p)
  13250. X#  define zread(f,b,n) read(f,b,n)
  13251. X#  define zclose(f) close(f)
  13252. X#  define zerr(f) (k==(extent)(-1L))
  13253. X#  define zstdin 0
  13254. X#endif /* ?VMS */
  13255. X
  13256. X
  13257. X/* Local data */
  13258. X
  13259. X#ifndef UTIL
  13260. Xlocal ulg crc;       /* crc on uncompressed file data */
  13261. Xlocal ftype ifile;   /* file to compress */
  13262. X#endif
  13263. Xulg isize;           /* input file size. global only for debugging */    
  13264. X
  13265. X/* Local functions */
  13266. X#if defined(PROTO) && !defined(UTIL)
  13267. X   local int suffixes(char *, char *);
  13268. X#endif
  13269. X
  13270. X
  13271. X/* Note: a zip "entry" includes a local header (which includes the file
  13272. X   name), an encryption header if encrypting, the compressed data
  13273. X   and possibly an extended local header. */
  13274. X
  13275. Xint zipcopy(z, x, y)
  13276. Xstruct zlist far *z;    /* zip entry to copy */
  13277. XFILE *x, *y;            /* source and destination files */
  13278. X/* Copy the zip entry described by *z from file *x to file *y.  Return an
  13279. X   error code in the ZE_ class.  Also update tempzn by the number of bytes
  13280. X   copied. */
  13281. X{
  13282. X  ulg n;                /* holds local header offset */
  13283. X
  13284. X  if (fseek(x, z->off, SEEK_SET))
  13285. X    return ferror(x) ? ZE_READ : ZE_EOF;
  13286. X  z->off = tempzn;
  13287. X  n = 4 + LOCHEAD + (long)z->nam + (long)z->ext + z->siz;
  13288. X  /* copy the extended local header if there is one */
  13289. X  if (z->lflg & 8) n += 16;
  13290. X  tempzn += n;
  13291. X  return fcopy(x, y, n);
  13292. X}
  13293. X
  13294. X
  13295. X#ifndef UTIL
  13296. X
  13297. Xint percent(n, m)
  13298. Xlong n, m;               /* n is the original size, m is the new size */
  13299. X/* Return the percentage compression from n to m using only integer
  13300. X   operations */
  13301. X{
  13302. X  if (n > 0xffffffL)            /* If n >= 16M */
  13303. X  {                             /*  then divide n and m by 256 */
  13304. X    n += 0x80;  n >>= 8;
  13305. X    m += 0x80;  m >>= 8;
  13306. X  }
  13307. X  return n ? (int)(1 + (200 * (n - m)/n)) / 2 : 0;
  13308. X}
  13309. X
  13310. Xlocal int suffixes(a, s)
  13311. Xchar *a;                /* name to check suffix of */
  13312. Xchar *s;                /* list of suffixes separated by : or ; */
  13313. X/* Return true if a ends in any of the suffixes in the list s. */
  13314. X{
  13315. X  int m;                /* true if suffix matches so far */
  13316. X  char *p;              /* pointer into special */
  13317. X  char *q;              /* pointer into name a */
  13318. X
  13319. X  m = 1;
  13320. X#ifdef VMS
  13321. X  if( (q = strrchr(a,';')) != NULL )    /* Cut out VMS file version */
  13322. X    --q;
  13323. X  else
  13324. X    q = a + strlen(a) - 1;
  13325. X#else
  13326. X  q = a + strlen(a) - 1;
  13327. X#endif
  13328. X  for (p = s + strlen(s) - 1; p >= s; p--)
  13329. X    if (*p == ':' || *p == ';')
  13330. X      if (m)
  13331. X        return 1;
  13332. X      else
  13333. X      {
  13334. X        m = 1;
  13335. X#ifdef VMS
  13336. X        if( (q = strrchr(a,';')) != NULL )      /* Cut out VMS file version */
  13337. X          --q;
  13338. X        else
  13339. X          q = a + strlen(a) - 1;
  13340. X#else
  13341. X        q = a + strlen(a) - 1;
  13342. X#endif
  13343. X      }
  13344. X    else
  13345. X    {
  13346. X      m = m && q >= a && case_map(*p) == case_map(*q);
  13347. X      q--;
  13348. X    }
  13349. X  return m;
  13350. X}
  13351. X
  13352. Xint zipup(z, y)
  13353. Xstruct zlist far *z;    /* zip entry to compress */
  13354. XFILE *y;                /* output file */
  13355. X/* Compress the file z->name into the zip entry described by *z and write
  13356. X   it to the file *y. Encrypt if requested.  Return an error code in the
  13357. X   ZE_ class.  Also, update tempzn by the number of bytes written. */
  13358. X{
  13359. X  ulg a = 0L;           /* attributes returned by filetime() */
  13360. X  char *b;              /* malloc'ed file buffer */
  13361. X  extent k = 0;         /* result of zread */
  13362. X  int l = 0;            /* true if this file is a symbolic link */
  13363. X  int m;                /* method for this entry */
  13364. X  ulg o, p;             /* offsets in zip file */
  13365. X  long q = -2L;         /* size returned by filetime */
  13366. X  int r;                /* temporary variable */
  13367. X  ulg s = 0L;           /* size of compressed data */
  13368. X
  13369. X  if ((z->tim = filetime(z->name, &a, &q)) == 0 || q < -1L)
  13370. X    return ZE_OPEN;
  13371. X  /* q is set to -1 if the input file is a device */
  13372. X
  13373. X  z->nam = strlen(z->zname);
  13374. X
  13375. X  /* Select method based on the suffix and the global method */
  13376. X  m = special != NULL && suffixes(z->name, special) ? STORE : method;
  13377. X
  13378. X  /* Open file to zip up unless it is stdin */
  13379. X  if (strcmp(z->name, "-") == 0)
  13380. X  {
  13381. X    ifile = (ftype)zstdin;
  13382. X#ifdef MSDOS
  13383. X    setmode(zstdin, O_BINARY);
  13384. X#endif
  13385. X  }
  13386. X  else
  13387. X  {
  13388. X#ifdef VMS
  13389. X   if (vms_native)
  13390. X     get_vms_attributes(z);
  13391. X#endif
  13392. X#ifdef OS2
  13393. X    GetEAs(z->name, &z->extra, &z->ext, &z->cextra, &z->cext);
  13394. X    /* store data in local header, and size only in central headers */
  13395. X#endif
  13396. X    l = issymlnk(a);
  13397. X    if (l)
  13398. X      ifile = fbad;
  13399. X    else if (z->name[z->nam - 1] == '/') { /* directory */
  13400. X      ifile = fbad;
  13401. X      m = STORE;
  13402. X    }
  13403. X    else if ((ifile = zopen(z->name, fhow)) == fbad)
  13404. X      return ZE_OPEN;
  13405. X  }
  13406. X
  13407. X  if (l || q == 0)
  13408. X    m = STORE;
  13409. X  if (m == BEST)
  13410. X    m = DEFLATE;
  13411. X
  13412. X  /* Do not create STORED files with extended local headers if the
  13413. X   * input size is not known, because such files could not be extracted.
  13414. X   * So if the zip file is not seekable and the input file is not
  13415. X   * on disk, obey the -0 option by forcing deflation with stored block.
  13416. X   * Note however that using "zip -0" as filter is not very useful...
  13417. X   * ??? to be done.
  13418. X   */
  13419. X
  13420. X  /* Fill in header information and write local header to zip file.
  13421. X   * This header will later be re-written since compressed length and
  13422. X   * crc are not yet known.
  13423. X   */
  13424. X
  13425. X  /* (Assume ext, cext, com, and zname already filled in.) */
  13426. X#ifdef OS2
  13427. X  z->vem = z->dosflag ? 20 :            /* Made under MSDOS by PKZIP 2.0 */
  13428. X  /* We for a FAT file system, we must cheat and pretend that the
  13429. X   * file was not made on OS2 but under DOS. unzip is confused otherwise.
  13430. X   */
  13431. X#else
  13432. X  z->vem = dosify ? 20 :                /* Made under MSDOS by PKZIP 2.0 */
  13433. X#endif
  13434. X#ifdef VMS
  13435. X                    0x200 + REVISION;   /* Made under VMS by this Zip */
  13436. X#else /* !VMS */
  13437. X# ifdef OS2
  13438. X                    0x600 + REVISION;   /* Made under OS/2 by this Zip */
  13439. X# else /* !OS2 */
  13440. X#  ifdef MSDOS
  13441. X                    0     + REVISION;   /* Made under MSDOS by this Zip */
  13442. X#  else
  13443. X                    0x300 + REVISION;   /* Made under Unix by this Zip */
  13444. X#  endif /* MSDOS */
  13445. X# endif /* ?OS2 */
  13446. X#endif /* ?VMS */
  13447. X
  13448. X  z->ver = 20;                          /* Need PKUNZIP 2.0 */
  13449. X  z->crc = 0;  /* to be updated later */
  13450. X  /* Assume first that we will need an extended local header: */
  13451. X  z->flg = 8;  /* to be updated later */
  13452. X#ifdef CRYPT
  13453. X  if (key != NULL) {
  13454. X    z->flg |= 1;
  13455. X    /* Since we do not yet know the crc here, we pretend that the crc
  13456. X     * is the modification time:
  13457. X     */
  13458. X    z->crc = z->tim << 16;
  13459. X  }
  13460. X#endif
  13461. X  z->lflg = z->flg;
  13462. X  z->how = m;                             /* may be changed later  */
  13463. X  z->siz = m == STORE && q >= 0 ? q : 0;  /* will be changed later  */
  13464. X  z->len = q >= 0 ? q : 0;                /* may be changed later  */
  13465. X  z->dsk = 0;
  13466. X  z->att = BINARY;                        /* may be changed later */
  13467. X  z->atx = z->dosflag ? a & 0xff : a;      /* Attributes from filetime() */
  13468. X  z->off = tempzn;
  13469. X  if ((r = putlocal(z, y)) != ZE_OK)
  13470. X    return r;
  13471. X  tempzn += 4 + LOCHEAD + z->nam + z->ext;
  13472. X
  13473. X#ifdef CRYPT
  13474. X  if (key != NULL) {
  13475. X    crypthead(key, z->crc, y);
  13476. X    z->siz += 12;  /* to be updated later */
  13477. X    tempzn += 12;
  13478. X  }
  13479. X#endif
  13480. X  o = ftell(y); /* for debugging only */
  13481. X
  13482. X  /* Write stored or deflated file to zip file */
  13483. X  isize = 0L;
  13484. X  crc = updcrc((char *)NULL, 0);
  13485. X
  13486. X  if (m == DEFLATE) {
  13487. X     bi_init(y);
  13488. X     z->att = (ush)UNKNOWN;
  13489. X     ct_init(&z->att, &m);
  13490. X     lm_init(level, &z->flg);
  13491. X     s = deflate();
  13492. X  }
  13493. X  else
  13494. X  {
  13495. X    if ((b = malloc(CBSZ)) == NULL)
  13496. X       return ZE_MEM;
  13497. X
  13498. X    if (z->name[z->nam - 1] != '/') /* no read for directories */
  13499. X    while ((k = l ? rdsymlnk(z->name, b, CBSZ) : zread(ifile, b, CBSZ)) > 0)
  13500. X    {
  13501. X      isize += k;
  13502. X      crc = updcrc(b, k);
  13503. X      if (zfwrite(b, 1, k, y) != k)
  13504. X      {
  13505. X        free((voidp *)b);
  13506. X        return ZE_TEMP;
  13507. X      }
  13508. X#ifdef MINIX
  13509. X      if (l)
  13510. X        q = k;
  13511. X#endif /* MINIX */
  13512. X      if (l)
  13513. X        break;
  13514. X    }
  13515. X    free((voidp *)b);
  13516. X    s = isize;
  13517. X  }
  13518. X  if (ifile != fbad && zerr(ifile))
  13519. X    return ZE_READ;
  13520. X  if (ifile != fbad)
  13521. X    zclose(ifile);
  13522. X
  13523. X  tempzn += s;
  13524. X  p = tempzn; /* save for future fseek() */
  13525. X
  13526. X#ifndef VMS
  13527. X  /* Check input size (but not in VMS--variable record lengths mess it up) */
  13528. X  if (q >= 0 && isize != (ulg)q && !translate_eol)
  13529. X  {
  13530. X    fprintf(mesg, " i=%ld, q=%ld ", isize, q);
  13531. X    error("incorrect input size");
  13532. X  }
  13533. X#endif /* !VMS */
  13534. X
  13535. X  /* Try to rewrite the local header with correct information */
  13536. X  z->crc = crc;
  13537. X  z->siz = s;
  13538. X#ifdef CRYPT
  13539. X  if (key != NULL)
  13540. X    z->siz += 12;
  13541. X#endif
  13542. X  z->len = isize;
  13543. X  if (fseek(y, z->off, SEEK_SET)) {
  13544. X    if (z->how != (ush) m)
  13545. X       error("can't rewrite method");
  13546. X    if (m == STORE && q < 0)
  13547. X       error("zip -0 not allowed for input/output from/to pipe or device");
  13548. X    if ((r = putextended(z, y)) != ZE_OK)
  13549. X      return r;
  13550. X    tempzn += 16L;
  13551. X    z->flg = z->lflg; /* if flg modified by inflate */
  13552. X  } else {
  13553. X     /* seek ok, ftell() should work, check compressed size */
  13554. X#ifndef VMS
  13555. X    if (p - o != s) {
  13556. X      fprintf(mesg, " s=%ld, actual=%ld ", s, p-o);
  13557. X      error("incorrect compressed size");
  13558. X    }
  13559. X#endif
  13560. X    z->how = m;
  13561. X    if ((z->flg & 1) == 0)
  13562. X      z->flg &= ~8; /* clear the extended local header flag */
  13563. X    z->lflg = z->flg;
  13564. X    /* rewrite the local header: */
  13565. X    if ((r = putlocal(z, y)) != ZE_OK)
  13566. X      return r;
  13567. X    if (fseek(y, p, SEEK_SET))
  13568. X      return ZE_READ;
  13569. X    if ((z->flg & 1) != 0) {
  13570. X      /* encrypted file, extended header still required */
  13571. X      if ((r = putextended(z, y)) != ZE_OK)
  13572. X        return r;
  13573. X      tempzn += 16L;
  13574. X    }
  13575. X  }
  13576. X
  13577. X  /* Display statistics */
  13578. X  if (noisy)
  13579. X  {
  13580. X    if (verbose)
  13581. X      fprintf(mesg, " (in=%lu) (out=%lu)", isize, s);
  13582. X    if (m == DEFLATE)
  13583. X      fprintf(mesg, " (deflated %d%%)\n", percent(isize, s));
  13584. X    else
  13585. X      fprintf(mesg, " (stored 0%%)\n");
  13586. X    fflush(mesg);
  13587. X  }
  13588. X  return ZE_OK;
  13589. X}
  13590. X
  13591. X
  13592. Xint file_read(buf, size)
  13593. X  char *buf;
  13594. X  unsigned size;
  13595. X/* Read a new buffer from the current input file, and update the crc and
  13596. X * input file size.
  13597. X * IN assertion: size >= 2 (for end-of-line translation)
  13598. X */
  13599. X{
  13600. X  unsigned len;
  13601. X  char far *b;
  13602. X  if (translate_eol) {
  13603. X    /* static char last_byte = '\0'; */
  13604. X    size >>= 1;
  13605. X    b = buf+size;
  13606. X    size = len = zread(ifile, b, size);
  13607. X    if (len == (unsigned)EOF || len == 0) return len;
  13608. X    do {
  13609. X       /* ??? keep cr lf intact */
  13610. X       if ((*buf++ = *b++) == '\n') *(buf-1) = '\r', *buf++ = '\n', len++;
  13611. X    } while (--size != 0);
  13612. X    buf -= len;
  13613. X  } else {
  13614. X    len = zread(ifile, buf, size);
  13615. X    if (len == (unsigned)EOF || len == 0) return len;
  13616. X  }
  13617. X  crc = updcrc(buf, len);
  13618. X  isize += (ulg)len;
  13619. X  return len;
  13620. X}
  13621. X#endif /* !UTIL */
  13622. END_OF_FILE
  13623.   if test 12100 -ne `wc -c <'zipup.c'`; then
  13624.     echo shar: \"'zipup.c'\" unpacked with wrong size!
  13625.   fi
  13626.   # end of 'zipup.c'
  13627. fi
  13628. echo shar: End of archive 8 \(of 11\).
  13629. cp /dev/null ark8isdone
  13630. MISSING=""
  13631. for I in 1 2 3 4 5 6 7 8 9 10 11 ; do
  13632.     if test ! -f ark${I}isdone ; then
  13633.     MISSING="${MISSING} ${I}"
  13634.     fi
  13635. done
  13636. if test "${MISSING}" = "" ; then
  13637.     echo You have unpacked all 11 archives.
  13638.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  13639. else
  13640.     echo You still must unpack the following archives:
  13641.     echo "        " ${MISSING}
  13642. fi
  13643. exit 0
  13644. exit 0 # Just in case...
  13645. Newsgroups: comp.sources.misc
  13646. From: zip-bugs@cs.ucla.edu (Info-ZIP group)
  13647. Subject:  v31i101:  zip19 - Info-ZIP portable Zip, version 1.9, Part09/11
  13648. Message-ID: <1992Aug23.064947.29627@sparky.imd.sterling.com>
  13649. X-Md4-Signature: 21a7f40fe6ce3bc3b1189116643da76f
  13650. Date: Sun, 23 Aug 1992 06:49:47 GMT
  13651. Approved: kent@sparky.imd.sterling.com
  13652.  
  13653. Submitted-by: zip-bugs@cs.ucla.edu (Info-ZIP group)
  13654. Posting-number: Volume 31, Issue 101
  13655. Archive-name: zip19/part09
  13656. Supersedes: zip: Volume 23, Issue 88-96
  13657. Environment: UNIX, VMS, OS/2, MS-DOS, MACINTOSH, WIN-NT, LINUX, MINIX, XOS, !AMIGA, ATARI, symlink, SGI, DEC, Cray, Convex, Amdahl, Sun, PC
  13658.  
  13659. #! /bin/sh
  13660. # This is a shell archive.  Remove anything before this line, then feed it
  13661. # into a shell via "sh file" or similar.  To overwrite existing files,
  13662. # type "sh file -c".
  13663. # The tool that generated this appeared in the comp.sources.unix newsgroup;
  13664. # send mail to comp-sources-unix@uunet.uu.net if you want that tool.
  13665. # Contents:  atari/makefile.st infozip.who mac/macfile.c mac/macstat.c
  13666. #   makefile msdos/makefile.msc.UU msdos/match.asm os2/match32.asm.UU
  13667. #   vms/VMSmunch.h vms/vaxclib.opt
  13668. # Wrapped by kent@sparky on Sun Aug 23 01:00:46 1992
  13669. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  13670. echo If this archive is complete, you will see the following message:
  13671. echo '          "shar: End of archive 9 (of 11)."'
  13672. if test -f 'atari/makefile.st' -a "${1}" != "-c" ; then 
  13673.   echo shar: Will not clobber existing file \"'atari/makefile.st'\"
  13674. else
  13675.   echo shar: Extracting \"'atari/makefile.st'\" \(1949 characters\)
  13676.   sed "s/^X//" >'atari/makefile.st' <<'END_OF_FILE'
  13677. X# Makefile for Zip, ZipNote and ZipSplit for
  13678. X# Atari ST with Turbo C 2.0.
  13679. X
  13680. X# To use, do "make -f makefile.st"
  13681. X
  13682. X# ------------- Turbo C -------------
  13683. XTCHOME=\TC
  13684. X
  13685. XCFLAGS=-A -G -I$(TCHOME)\INCLUDE -DATARI_ST
  13686. XUTILFLAGS=-DUTIL $(CFLAGS)
  13687. XCC=tcc
  13688. XLD=tlink
  13689. XLDFLAGS= -S=8192
  13690. X
  13691. X# variables
  13692. XOBJZ = zip.o zipfile.o zipup.o fileio.o util.o globals.o atari.o
  13693. XOBJI = deflate.o trees.o bits.o
  13694. X
  13695. XOBJU = zipfile_.o zipup_.o fileio_.o util_.o globals.o
  13696. XOBJN = zipnote.o  $(OBJU)
  13697. XOBJS = zipsplit.o $(OBJU)
  13698. X
  13699. Xzips:    zip.prg zipnote.prg zipsplit.prg
  13700. X    echo done
  13701. X
  13702. Xatari.o: atari.c
  13703. X    $(CC) -c $(CFLAGS) atari.c
  13704. X
  13705. Xzip.o:    zip.h ziperr.h tailor.h revision.h zip.c
  13706. X    $(CC) -c $(CFLAGS) zip.c
  13707. X
  13708. Xzipfile.o:    zip.h ziperr.h tailor.h zipfile.c
  13709. X    $(CC) -c $(CFLAGS) zipfile.c
  13710. X
  13711. Xzipup.o:    zip.h ziperr.h tailor.h revision.h zipup.c
  13712. X    $(CC) -c $(CFLAGS) zipup.c
  13713. X
  13714. Xfileio.o:    zip.h ziperr.h tailor.h fileio.c
  13715. X    $(CC) -c $(CFLAGS) fileio.c
  13716. X
  13717. Xutil.o:    zip.h ziperr.h tailor.h util.c
  13718. X    $(CC) -c $(CFLAGS) util.c
  13719. X
  13720. Xglobals.o:    zip.h ziperr.h tailor.h globals.c
  13721. X    $(CC) -c $(CFLAGS) globals.c
  13722. X
  13723. Xzipnote.o:    zip.h ziperr.h tailor.h revision.h zipnote.c
  13724. X    $(CC) -c $(CFLAGS) zipnote.c
  13725. X
  13726. Xzipsplit.o:    zipsplit.c zip.h ziperr.h tailor.h revision.h
  13727. X    $(CC) -c $(CFLAGS) zipsplit.c
  13728. X
  13729. Xdeflate.o:    zip.h ziperr.h tailor.h deflate.c
  13730. X    $(CC) -c $(CFLAGS) deflate.c
  13731. X
  13732. Xtrees.o:    zip.h ziperr.h tailor.h trees.c
  13733. X    $(CC) -c $(CFLAGS) trees.c
  13734. X
  13735. Xbits.o:        zip.h ziperr.h tailor.h bits.c
  13736. X    $(CC) -c $(CFLAGS) bits.c
  13737. X
  13738. Xzipfile_.o:    zipfile.c zip.h ziperr.h tailor.h
  13739. X    $(CC) -c $(UTILFLAGS) -Ozipfile_.o zipfile.c
  13740. X
  13741. Xzipup_.o:    zipup.c zip.h ziperr.h tailor.h
  13742. X    $(CC) -c $(UTILFLAGS) -Ozipup_.o zipup.c
  13743. X
  13744. Xfileio_.o:    fileio.c zip.h ziperr.h tailor.h
  13745. X    $(CC) -c $(UTILFLAGS) -Ofileio_.o fileio.c
  13746. X
  13747. Xutil_.o:    util.c zip.h ziperr.h tailor.h
  13748. X    $(CC) -c $(UTILFLAGS) -Ofileio_.o fileio.c
  13749. X
  13750. Xzip.prg: $(OBJZ) $(OBJI)
  13751. X    $(LD) $(LDFLAGS) -C=zip.lnk -O=$@
  13752. X
  13753. Xzipnote.prg: $(OBJN)
  13754. X    $(LD) $(LDFLAGS) -C=zipn.lnk -O=$@
  13755. X
  13756. Xzipsplit.prg: $(OBJS)
  13757. X    $(LD) $(LDFLAGS) -C=zips.lnk -O=$@
  13758. END_OF_FILE
  13759.   if test 1949 -ne `wc -c <'atari/makefile.st'`; then
  13760.     echo shar: \"'atari/makefile.st'\" unpacked with wrong size!
  13761.   fi
  13762.   # end of 'atari/makefile.st'
  13763. fi
  13764. if test -f 'infozip.who' -a "${1}" != "-c" ; then 
  13765.   echo shar: Will not clobber existing file \"'infozip.who'\"
  13766. else
  13767.   echo shar: Extracting \"'infozip.who'\" \(6165 characters\)
  13768.   sed "s/^X//" >'infozip.who' <<'END_OF_FILE'
  13769. XThese members of the INFO-ZIP group contributed to the development and
  13770. Xtesting of portable Zip.  They are responsible for whatever works in Zip.
  13771. XWhatever doesn't work is solely the fault of the authors of Zip (Mark Adler,
  13772. XRich Wales, Jean-loup Gailly, Kai Uwe Rommel and Igor Mandrichenko).
  13773. XBill Davidsen provided the envargs code. If you have contributed and
  13774. Xyour name has been forgotten, please send a reminder to the zip-bugs
  13775. Xaddress given in the Readme file.
  13776. X
  13777. XMark Adler              madler@tybalt.caltech.edu       NeXT 2.x
  13778. XGlenn J. Andrews        oper1%drcv06.decnet@drcvax.af.mil       VAX VMS
  13779. XTom Betz                marob!upaya!tbetz@phri.nyu.edu  SCO Xenix 2.3.1
  13780. XJames Birdsall          jwbirdsa@amc.com                AT&T 3B1
  13781. XWim Bonner              27313853@WSUVM1.CSC.WSU.EDU     HP 9000/840a HPUX
  13782. XPaul Borman             prb@cray.com                    Cray-X/YMP,2 UNICOS 6-8
  13783. XLeslie C. Brown         lbrown@BRL.MIL                  Pyramid MIS-4
  13784. XRalf Brown              ralf@b.gp.cs.cmu.edu            Pyramid MIS-4
  13785. XPietro Caselli          zaphod@petruz.sublink.org       Minix 1.5.10
  13786. XBill Davidsen           davidsen@crdos1.crd.ge.com      Xenix (on what?)
  13787. XDaniel Deimert          daniel@hexagon.se               zeus3.21 Zilog S8000
  13788. XJames P. Dugal          jpd@usl.edu                     Pyramid 90X OSx4.1
  13789. X"Evil Ed"               esaffle@gmuvax2.gmu.edu         Ulrix-32 V3.1 (Rev. 9)
  13790. XDavid A. Feinleib       t-davefe@microsoft.com          Windows NT
  13791. XGreg Flint              afc@klaatu.cc.purdue.edu        ETA-10P* hybrid Sys V
  13792. XJeff Foy                jfoy@glia.biostr.washington.edu IRIX Sys V Rel 3.3.1
  13793. XMike Freeman            freeman@watsun.cc.columbia.edu  Vax VMS
  13794. XKevin M. Fritz          kmfritz@apgea.army.mil          Turbo C++ 1.0
  13795. XJean-loup Gailly        jloup@chorus.fr                 MS-DOS Microsoft C 5.1
  13796. XScott D. Galloway       sgallowa@letterkenn-emh1.army.mil   Sperry 5000 SysV.3
  13797. XGeorge Grimes           grimes@netcom.com               Apollo Domain SR10.4
  13798. XHunter Goatley          goathunter@WKUVX1.BITNET        Vax VMS
  13799. XArnt Gulbrandsen        agulbra@pvv.unit.no             Linux
  13800. XDavid Gundlach          david@rolf.stat.uga.edu         Sun SS1+ SunOS 4.1
  13801. XBob Hardy               hardy@lucid.com                 Power C on MSDOS
  13802. XPeter Jones             jones@mips1.info.uqam.ca        MIPS UMIPS 4.0
  13803. XKjetil W. J{\o}rgensen  jorgens@lise.unit.no            OSF/1
  13804. XBruce Kahn              bkahn@archive.webo.dg.com       MS-DOS Microsoft C 5.1
  13805. XJonathan I. Kamens      jik@pit-manager.mit.edu         ultrix on DECstation
  13806. XBob Kemp                Robert.V.Kemp@att.com           AT&T 3B2 SysV 3.2v2
  13807. XEarl Kiech              KIECH@utkvx.utk.edu             VAX VMS V5.4-1A
  13808. XDavid Kirschbaum        kirsch@usasoc.soc.mil           He got us all in this
  13809. X                                                        mess in the first place
  13810. XBo Kullmar              bk@kullmar.se                   DNIX 5.2, 5.3
  13811. XHarry Langenbacher      harry@neuron6.Jpl.Nasa.Gov      Sun SS1+ SunOS 4.1
  13812. XMichael D. Lawler       mdlawler@bsu-cs.bsu.edu         Mt.Xinu BSD 4.3 on VAX
  13813. XJohnny Lee              johnnyl@microsoft.com           Microsoft C 7.0
  13814. XDavid Lemson            lemson@ux1.cso.uiuc.edu         Sequent Dynix 3.0.17
  13815. XOnno van der Linden     vdlinden@fwi.uva.nl             SCO Unix 3.2.0
  13816. X                                                        BC++ 3.0, djgcc 1.06
  13817. XWarner Losh             imp@Solbourne.COM               packing algorithm help
  13818. XJohn Lundin             lundin@urvax.urich.edu          VAX VMS
  13819. XIgor Mandrichenko       mandrichenko@m10.ihep.su        VAX VMS
  13820. XCliff Manis             root@csoftec.csf.com            SCO 2.3.1 (386)
  13821. XFulvio Marino           fulvio@iconet.ico.olivetti.it   X/OS 2.3 & 2.4
  13822. XBill Marsh              bmarsh@cod.nosc.mil             SGI Iris 4D35
  13823. XPeter Mauzey            ptm@mtdcc.att.com               AT&T 6300
  13824. XRafal Z. Maszkowski     <rzm%pltumk11.bitnet@mvs.oac.ucla.edu> Bug report
  13825. XRobert McBroom (?)      rm3@ornl.gov                    DECsystem 5810
  13826. XHumberto Ortiz-Zuazaga  zuazaga@ucunix.san.uc.edu       Linux
  13827. XJames E. O'Dell         jim@fpr.com                     MacOS
  13828. XWilliam O'Shaughnessy   williamo@hpcupt1.cup.hp.com     HPUX
  13829. XEnrico Renato Palmerini palmer@vxscaq.cineca.it         UNISYS 7000 Sys 5 r2.3
  13830. XKeith Petersen          w8sdz@simtel20.army.mil         Maintainer of Info-ZIP
  13831. X                                                        Pyramid UCB OSx4.4c
  13832. XDavid A Rasmussen       dave@convex.csd.uwm.edu         Convex C220 with 9.0 OS
  13833. XMichael Regoli          mr@cica.indiana.edu             Ultrix 3.1 VAX 8650
  13834. X                                                        BSD 4.3 IBM RT/125
  13835. X                                                        BSD 4.3 MicroVAX 3500
  13836. X                                                        SunOS 4.0.3 Sun 4/330
  13837. XRick Rodgers            rodgers@maxwell.mmwb.ucsf.EDU   Unix man page
  13838. XGreg Roelofs            roe2@midway.uchicago.edu        SunOS 4.1.1,4.1.2 Sun 4
  13839. X                                                        Unicos 5.1--6.1.5 Cray
  13840. X                                                        OS/2 1.3 MS C 6.0
  13841. X                                                        Ultrix 4.1,4.2 DEC 5810
  13842. X                                                        VMS 5.2, 5.4 VAX 8600
  13843. X                                                        Irix 3.3.2, SGI Iris 4D
  13844. X                                                        UTS 1.2.4 Amdahl 5880
  13845. XKai Uwe Rommel          rommel@informatik.tu-muenchen.de        OS/2
  13846. XJon Saxton              jrs@panix.com                   Microsoft C 6.0
  13847. XSteve Salisbury         stevesa@microsoft.com           Microsoft C 6.0
  13848. XMartin Schulz           martin@indian.cs.unb.ca         Atari ST
  13849. XDave Sisson             daves@vtcosy.cns.vt.edu         AIX 1.1.1 PS/2 & 3090
  13850. XRon Srodawa             srodawa@vela.acs.oakland.edu    SCO Xenix/386 2.3.3
  13851. XBertil Stenstr|m        stenis@heron.qz.se              HP-UX 7.0 HP9000/835
  13852. XAntoine Verheijen    antoine@sysmail.ucs.ualberta.ca envargs fix
  13853. XArjan de Vet            devet@info.win.tue.nl           SunOS 4.1, MSC 5.1
  13854. XRich Wales              wales@cs.ucla.edu               SunOS 4.0.3 Sun-3/50
  13855. END_OF_FILE
  13856.   if test 6165 -ne `wc -c <'infozip.who'`; then
  13857.     echo shar: \"'infozip.who'\" unpacked with wrong size!
  13858.   fi
  13859.   # end of 'infozip.who'
  13860. fi
  13861. if test -f 'mac/macfile.c' -a "${1}" != "-c" ; then 
  13862.   echo shar: Will not clobber existing file \"'mac/macfile.c'\"
  13863. else
  13864.   echo shar: Extracting \"'mac/macfile.c'\" \(6797 characters\)
  13865.   sed "s/^X//" >'mac/macfile.c' <<'END_OF_FILE'
  13866. X/*---------------------------------------------------------------------------
  13867. X
  13868. X  macfile.c
  13869. X
  13870. X  This source file is used by the mac port to support commands not available
  13871. X  directly on the Mac, i.e. mkdir().
  13872. X  It also helps determine if we're running on a Mac with HFS and a disk
  13873. X  formatted for HFS (HFS - Hierarchical File System; compared to its predecessor,
  13874. X  MFS - Macintosh File System).
  13875. X  
  13876. X  ---------------------------------------------------------------------------*/
  13877. X
  13878. X#include "unzip.h"
  13879. X
  13880. X#ifdef MACOS
  13881. X#ifndef FSFCBLen
  13882. X#define FSFCBLen    (*(short *)0x3F6)
  13883. X#endif
  13884. X
  13885. Xstatic short wAppVRefNum;
  13886. Xstatic long lAppDirID;
  13887. Xint hfsflag;            /* set if disk has hierarchical file system */
  13888. X
  13889. Xstatic int IsHFSDisk(short wRefNum)
  13890. X{
  13891. X    /* get info about the specified volume */
  13892. X    if (hfsflag == true) {
  13893. X        HParamBlockRec    hpbr;
  13894. X        Str255 temp;
  13895. X        short wErr;
  13896. X        
  13897. X        hpbr.volumeParam.ioCompletion = 0;
  13898. X        hpbr.volumeParam.ioNamePtr = temp;
  13899. X        hpbr.volumeParam.ioVRefNum = wRefNum;
  13900. X        hpbr.volumeParam.ioVolIndex = 0;
  13901. X        wErr = PBHGetVInfo(&hpbr, 0);
  13902. X
  13903. X        if (wErr == noErr && hpbr.volumeParam.ioVFSID == 0
  13904. X            && hpbr.volumeParam.ioVSigWord == 0x4244) {
  13905. X                return true;
  13906. X        }
  13907. X    }
  13908. X
  13909. X    return false;
  13910. X} /* IsHFSDisk */
  13911. X
  13912. Xvoid macfstest(int vrefnum)
  13913. X{
  13914. X    Str255 st;
  13915. X
  13916. X    /* is this machine running HFS file system? */
  13917. X    if (FSFCBLen <= 0) {
  13918. X        hfsflag = false;
  13919. X    }
  13920. X    else
  13921. X    {
  13922. X        hfsflag = true;
  13923. X    }
  13924. X
  13925. X    /* get the file's volume reference number and directory ID */
  13926. X    if (hfsflag == true) {
  13927. X        WDPBRec    wdpb;
  13928. X        OSErr err = noErr;
  13929. X
  13930. X        if (vrefnum != 0) {
  13931. X            wdpb.ioCompletion = false;
  13932. X            wdpb.ioNamePtr = st;
  13933. X            wdpb.ioWDIndex = 0;
  13934. X            wdpb.ioVRefNum = vrefnum;
  13935. X            err = PBHGetVol(&wdpb, false);
  13936. X        
  13937. X            if (err == noErr) {
  13938. X                wAppVRefNum = wdpb.ioWDVRefNum;
  13939. X                lAppDirID = wdpb.ioWDDirID;
  13940. X            }
  13941. X        }
  13942. X
  13943. X        /* is the disk we're using formatted for HFS? */
  13944. X        hfsflag = IsHFSDisk(wAppVRefNum);
  13945. X    }
  13946. X    
  13947. X    return;
  13948. X} /* mactest */
  13949. X
  13950. Xint macmkdir(char *path, short nVRefNum, long lDirID)
  13951. X{
  13952. X    OSErr    err = -1;
  13953. X
  13954. X    if (path != 0 && strlen(path)<256 && hfsflag == true) {
  13955. X        HParamBlockRec    hpbr;
  13956. X        Str255    st;
  13957. X
  13958. X        CtoPstr(path);
  13959. X        if ((nVRefNum == 0) && (lDirID == 0))
  13960. X        {
  13961. X            hpbr.fileParam.ioNamePtr = st;
  13962. X            hpbr.fileParam.ioCompletion = NULL;
  13963. X            err = PBHGetVol((WDPBPtr)&hpbr, false);
  13964. X            nVRefNum = hpbr.wdParam.ioWDVRefNum;
  13965. X            lDirID = hpbr.wdParam.ioWDDirID;
  13966. X        }
  13967. X        else
  13968. X        {
  13969. X            err = noErr;
  13970. X        }
  13971. X        if (err == noErr) {
  13972. X            hpbr.fileParam.ioCompletion = NULL;
  13973. X            hpbr.fileParam.ioVRefNum = nVRefNum;
  13974. X            hpbr.fileParam.ioDirID = lDirID;
  13975. X            hpbr.fileParam.ioNamePtr = (StringPtr)path;
  13976. X            err = PBDirCreate(&hpbr, false);
  13977. X        }    
  13978. X        PtoCstr(path);
  13979. X    }
  13980. X
  13981. X    return (int)err;
  13982. X} /* mkdir */
  13983. X
  13984. Xvoid ResolveMacVol(short nVRefNum, short *pnVRefNum, long *plDirID, StringPtr pst)
  13985. X{
  13986. X    if (hfsflag)
  13987. X    {
  13988. X        WDPBRec  wdpbr;
  13989. X        Str255   st;
  13990. X        OSErr    err;
  13991. X
  13992. X        wdpbr.ioCompletion = (ProcPtr)NULL;
  13993. X        wdpbr.ioNamePtr = st;
  13994. X        wdpbr.ioVRefNum = nVRefNum;
  13995. X        wdpbr.ioWDIndex = 0;
  13996. X        wdpbr.ioWDProcID = 0;
  13997. X        wdpbr.ioWDVRefNum = 0;
  13998. X        err = PBGetWDInfo( &wdpbr, false );
  13999. X        if ( err == noErr )
  14000. X        {
  14001. X            if (pnVRefNum)
  14002. X                *pnVRefNum = wdpbr.ioWDVRefNum;
  14003. X            if (plDirID)
  14004. X                *plDirID = wdpbr.ioWDDirID;
  14005. X            if (pst)
  14006. X                BlockMove( st, pst, st[0]+1 );
  14007. X        }
  14008. X    }
  14009. X    else
  14010. X    {
  14011. X        if (pnVRefNum)
  14012. X            *pnVRefNum = nVRefNum;
  14013. X        if (plDirID)
  14014. X            *plDirID = 0;
  14015. X        if (pst)
  14016. X            *pst = 0;
  14017. X    }
  14018. X}
  14019. X
  14020. Xshort macopen(char *sz, short nFlags, short nVRefNum, long lDirID)
  14021. X{
  14022. X    OSErr   err;
  14023. X    Str255  st;
  14024. X    char    chPerms = (!nFlags) ? fsRdPerm : fsRdWrPerm;
  14025. X    short   nFRefNum;
  14026. X
  14027. X    CtoPstr( sz );
  14028. X    BlockMove( sz, st, sz[0]+1 );
  14029. X    PtoCstr( sz );
  14030. X    if (hfsflag)
  14031. X    {
  14032. X        if (nFlags > 1)
  14033. X            err = HOpenRF( nVRefNum, lDirID, st, chPerms, &nFRefNum);
  14034. X        else
  14035. X            err = HOpen( nVRefNum, lDirID, st, chPerms, &nFRefNum);
  14036. X    }
  14037. X    else
  14038. X    {
  14039. X        /*
  14040. X         * Have to use PBxxx style calls since the high level
  14041. X         * versions don't support specifying permissions
  14042. X         */
  14043. X        ParamBlockRec    pbr;
  14044. X
  14045. X        pbr.ioParam.ioNamePtr = st;
  14046. X        pbr.ioParam.ioVRefNum = gnVRefNum;
  14047. X        pbr.ioParam.ioVersNum = 0;
  14048. X        pbr.ioParam.ioPermssn = chPerms;
  14049. X        pbr.ioParam.ioMisc = 0;
  14050. X        if (nFlags >1)
  14051. X            err = PBOpenRF( &pbr, false );
  14052. X        else
  14053. X            err = PBOpen( &pbr, false );
  14054. X        nFRefNum = pbr.ioParam.ioRefNum;
  14055. X    }
  14056. X    if ( err )
  14057. X        return -1;
  14058. X    else
  14059. X        return nFRefNum;
  14060. X}
  14061. X
  14062. Xshort maccreat(char *sz, short nVRefNum, long lDirID, OSType ostCreator, OSType ostType)
  14063. X{
  14064. X    OSErr   err;
  14065. X    Str255  st;
  14066. X    FInfo   fi;
  14067. X
  14068. X    CtoPstr( sz );
  14069. X    BlockMove( sz, st, sz[0]+1 );
  14070. X    PtoCstr( sz );
  14071. X    if (hfsflag)
  14072. X    {
  14073. X        err = HGetFInfo( nVRefNum, lDirID, st, &fi );
  14074. X        if (err == fnfErr)
  14075. X            err = HCreate( nVRefNum, lDirID, st, ostCreator, ostType );
  14076. X        else if (err == noErr)
  14077. X        {
  14078. X            fi.fdCreator = ostCreator;
  14079. X            fi.fdType = ostType;
  14080. X            err = HSetFInfo( nVRefNum, lDirID, st, &fi );
  14081. X        }
  14082. X    }
  14083. X    else
  14084. X    {
  14085. X        err = GetFInfo( st, nVRefNum, &fi );
  14086. X        if (err == fnfErr)
  14087. X            err = Create( st, nVRefNum, ostCreator, ostType );
  14088. X        else if (err == noErr)
  14089. X        {
  14090. X            fi.fdCreator = ostCreator;
  14091. X            fi.fdType = ostType;
  14092. X            err = SetFInfo( st, nVRefNum, &fi );
  14093. X        }
  14094. X    }
  14095. X    if (err == noErr)
  14096. X        return noErr;
  14097. X    else
  14098. X        return -1;
  14099. X}
  14100. X
  14101. Xshort macread(short nFRefNum, char *pb, unsigned cb)
  14102. X{
  14103. X    long    lcb = cb;
  14104. X
  14105. X    (void)FSRead( nFRefNum, &lcb, pb );
  14106. X
  14107. X    return (short)lcb;
  14108. X}
  14109. X
  14110. Xshort macwrite(short nFRefNum, char *pb, unsigned cb)
  14111. X{
  14112. X    long    lcb = cb;
  14113. X
  14114. X    (void)FSWrite( nFRefNum, &lcb, pb );
  14115. X
  14116. X    return (short)lcb;
  14117. X}
  14118. X
  14119. Xshort macclose(short nFRefNum)
  14120. X{
  14121. X    return FSClose( nFRefNum );
  14122. X}
  14123. X
  14124. Xlong maclseek(short nFRefNum, long lib, short nMode)
  14125. X{
  14126. X    ParamBlockRec   pbr;
  14127. X
  14128. X    if (nMode == SEEK_SET)
  14129. X        nMode = fsFromStart;
  14130. X    else if (nMode == SEEK_CUR)
  14131. X        nMode = fsFromMark;
  14132. X    else if (nMode == SEEK_END)
  14133. X        nMode = fsFromLEOF;
  14134. X    pbr.ioParam.ioRefNum = nFRefNum;
  14135. X    pbr.ioParam.ioPosMode = nMode;
  14136. X    pbr.ioParam.ioPosOffset = lib;
  14137. X    (void)PBSetFPos(&pbr, 0);
  14138. X    return pbr.ioParam.ioPosOffset;
  14139. X}
  14140. X
  14141. X#endif /* MACOS */
  14142. END_OF_FILE
  14143.   if test 6797 -ne `wc -c <'mac/macfile.c'`; then
  14144.     echo shar: \"'mac/macfile.c'\" unpacked with wrong size!
  14145.   fi
  14146.   # end of 'mac/macfile.c'
  14147. fi
  14148. if test -f 'mac/macstat.c' -a "${1}" != "-c" ; then 
  14149.   echo shar: Will not clobber existing file \"'mac/macstat.c'\"
  14150. else
  14151.   echo shar: Extracting \"'mac/macstat.c'\" \(5863 characters\)
  14152.   sed "s/^X//" >'mac/macstat.c' <<'END_OF_FILE'
  14153. X#ifdef THINK_C
  14154. X#define MACOS
  14155. X#include    <pascal.h>
  14156. X#endif
  14157. X#ifdef MPW
  14158. X#define MACOS
  14159. X#include    <Files.h>
  14160. X#include    <Errors.h>
  14161. X#define FSFCBLen    (*(short *)0x3F6)
  14162. X#define CtoPstr c2pstr
  14163. X#define PtoCstr p2cstr
  14164. X#endif
  14165. X
  14166. X#ifdef MACOS
  14167. X#include    <string.h>
  14168. X#include    "macstat.h"
  14169. Xint macstat(char *path, struct stat *buf, short nVRefNum, long lDirID );
  14170. X
  14171. X#define unixTime(t) ((t) = ((t) < (time_t)0x7c25b080) ? 0 : (t) - (time_t)0x7c25b080)
  14172. X
  14173. X/* assume that the path will contain a Mac-type pathname, i.e. ':'s, etc. */
  14174. Xint macstat(char *path, struct stat *buf, short nVRefNum, long lDirID )
  14175. X{
  14176. X    char    temp[256];
  14177. X    short   nVRefNumT;
  14178. X    long    lDirIDT;
  14179. X    short   fIsHFS = false;
  14180. X    OSErr   err;
  14181. X    short   fUseDefault = ((nVRefNum == 0) && (lDirID == 0));
  14182. X
  14183. X    if (buf == (struct stat *)0L || path == (char *)0L) {
  14184. X        SysBeep(1);
  14185. X        return -1;
  14186. X    }
  14187. X
  14188. X    if (path[0] == '\0' || strlen(path)>255) {
  14189. X        return -1;
  14190. X    }
  14191. X
  14192. X    if ( fUseDefault )
  14193. X    {
  14194. X        if (GetVol((StringPtr)&temp[0], &nVRefNumT) != noErr) {
  14195. X            SysBeep(1);
  14196. X            return -1;
  14197. X        }
  14198. X    }
  14199. X
  14200. X    /* get info about the specified volume */
  14201. X    if (FSFCBLen > 0)   /* HFS Disk? */
  14202. X    {
  14203. X        HParamBlockRec    hpbr;
  14204. X
  14205. X        if ( fUseDefault )
  14206. X        {
  14207. X            WDPBRec wdpb;
  14208. X    
  14209. X            wdpb.ioCompletion = 0;
  14210. X            wdpb.ioNamePtr = (StringPtr)temp;
  14211. X            err = PBHGetVol(&wdpb, 0);
  14212. X            nVRefNumT = wdpb.ioWDVRefNum;
  14213. X            lDirIDT = wdpb.ioWDDirID;
  14214. X        }
  14215. X        else
  14216. X        {
  14217. X            nVRefNumT = nVRefNum;
  14218. X            lDirIDT = lDirID;
  14219. X            err = noErr;
  14220. X        }
  14221. X        if (err == noErr)
  14222. X        {
  14223. X            hpbr.volumeParam.ioCompletion = 0;
  14224. X            hpbr.volumeParam.ioNamePtr = (StringPtr)temp;
  14225. X            hpbr.volumeParam.ioVRefNum = nVRefNumT;
  14226. X            hpbr.volumeParam.ioVolIndex = 0;
  14227. X            err = PBHGetVInfo(&hpbr, 0);
  14228. X
  14229. X            if (err == noErr && hpbr.volumeParam.ioVFSID == 0
  14230. X                && hpbr.volumeParam.ioVSigWord == 0x4244) {
  14231. X                    fIsHFS = true;
  14232. X            }
  14233. X        }
  14234. X    }
  14235. X
  14236. X
  14237. X    /* number of links, at least in System 6.0x, 0 */
  14238. X    buf->st_nlink = 0;
  14239. X    /* user id */
  14240. X    buf->st_uid = 0;
  14241. X    /* group id */
  14242. X    buf->st_gid = 0;
  14243. X
  14244. X    if (fIsHFS == true)   /* HFS? */
  14245. X    {
  14246. X        CInfoPBRec  cPB;
  14247. X        HParamBlockRec  hPB;
  14248. X
  14249. X        /* get information about file */
  14250. X        cPB.hFileInfo.ioCompletion = (ProcPtr)0L;
  14251. X        CtoPstr(path);
  14252. X        strncpy(temp,path, path[0]+1);
  14253. X        PtoCstr(path);
  14254. X        cPB.hFileInfo.ioNamePtr = (StringPtr)temp;
  14255. X        cPB.hFileInfo.ioVRefNum = nVRefNumT;
  14256. X        cPB.hFileInfo.ioDirID = lDirIDT;
  14257. X        cPB.hFileInfo.ioFDirIndex = 0;
  14258. X
  14259. X        err = PBGetCatInfo(&cPB, false); 
  14260. X
  14261. X        if (err != noErr) {
  14262. X            if (err != fnfErr) {
  14263. X                SysBeep(1);
  14264. X            }
  14265. X            return -1;
  14266. X        }
  14267. X        
  14268. X        /* Type of file: directory or regular file + access */
  14269. X        buf->st_mode = (cPB.hFileInfo.ioFlAttrib & ioDirMask) ? S_IFDIR : S_IFREG |
  14270. X                       (cPB.hFileInfo.ioFlAttrib & 0x01) ? S_IREAD : (S_IREAD | S_IWRITE);
  14271. X        
  14272. X        /* last access time, modification time and creation time(?) */
  14273. X        buf->st_atime = buf->st_mtime = cPB.hFileInfo.ioFlMdDat;
  14274. X        buf->st_ctime = cPB.hFileInfo.ioFlCrDat;
  14275. X        /* dev number */
  14276. X        buf->st_dev = (long)cPB.hFileInfo.ioVRefNum;
  14277. X        /* inode number */
  14278. X        buf->st_ino = cPB.hFileInfo.ioDirID;
  14279. X        /* size of file - use only the data fork */
  14280. X        buf->st_size = cPB.hFileInfo.ioFlLgLen;
  14281. X
  14282. X        /* size of disk block */
  14283. X        hPB.volumeParam.ioCompletion = (ProcPtr)0L;
  14284. X        hPB.volumeParam.ioNamePtr = (StringPtr)temp;
  14285. X        hPB.volumeParam.ioVRefNum = nVRefNumT;
  14286. X        hPB.volumeParam.ioVolIndex = 0;
  14287. X
  14288. X        err = PBHGetVInfo(&hPB, false);
  14289. X
  14290. X        if (err != noErr) {
  14291. X            SysBeep(1);
  14292. X            return -1;
  14293. X        }
  14294. X            
  14295. X        buf->st_blksize = cPB.hFileInfo.ioFlPyLen / hPB.volumeParam.ioVAlBlkSiz;
  14296. X    }
  14297. X    else    /* MFS? */
  14298. X    {
  14299. X        ParamBlockRec   pPB;
  14300. X        ParamBlockRec   hPB;
  14301. X
  14302. X        CtoPstr(path);
  14303. X        strncpy(temp, path, path[0]+1);
  14304. X        PtoCstr(path);
  14305. X        pPB.fileParam.ioCompletion = (ProcPtr)0;
  14306. X        pPB.fileParam.ioNamePtr = (StringPtr)temp;
  14307. X        pPB.fileParam.ioVRefNum = nVRefNumT;
  14308. X        pPB.fileParam.ioFVersNum = 0;
  14309. X        pPB.fileParam.ioFDirIndex = 0;
  14310. X
  14311. X        err = PBGetFInfo(&pPB, false);
  14312. X
  14313. X        if (err != noErr) {
  14314. X            SysBeep(1);
  14315. X            return -1;
  14316. X        }
  14317. X
  14318. X        /* Type of file: either directory or regular file + access */
  14319. X        buf->st_mode = (pPB.fileParam.ioFlAttrib & ioDirMask) ? S_IFDIR : S_IFREG;
  14320. X                       (pPB.fileParam.ioFlAttrib & 0x01) ? S_IREAD : (S_IREAD | S_IWRITE);
  14321. X
  14322. X        /* last access time, modification time and creation time(?) */
  14323. X        buf->st_atime = buf->st_mtime = pPB.fileParam.ioFlMdDat;
  14324. X        buf->st_ctime = pPB.fileParam.ioFlCrDat;
  14325. X        /* dev number */
  14326. X        buf->st_dev = (long)pPB.fileParam.ioVRefNum;
  14327. X        /* inode number */
  14328. X        buf->st_ino = pPB.fileParam.ioFlNum;
  14329. X        /* size of file - use only the data fork */
  14330. X        buf->st_size = pPB.fileParam.ioFlLgLen;
  14331. X
  14332. X        /* size of disk block */
  14333. X        hPB.volumeParam.ioCompletion = (ProcPtr)0;
  14334. X        hPB.volumeParam.ioNamePtr = (StringPtr)temp;
  14335. X        hPB.volumeParam.ioVRefNum = nVRefNumT;
  14336. X        hPB.volumeParam.ioVolIndex = 0;
  14337. X
  14338. X        err = PBGetVInfo(&hPB, false);
  14339. X
  14340. X        if (err != noErr) {
  14341. X            SysBeep(1);
  14342. X            return -1;
  14343. X        }
  14344. X
  14345. X        buf->st_blksize = pPB.fileParam.ioFlPyLen / hPB.volumeParam.ioVAlBlkSiz;
  14346. X    }
  14347. X
  14348. X    /* Convert from Macintosh time format to Unix time format. */
  14349. X
  14350. X    unixTime(buf->st_atime);
  14351. X    unixTime(buf->st_mtime);
  14352. X    unixTime(buf->st_ctime);
  14353. X
  14354. X    return 0;
  14355. X}
  14356. X#else
  14357. X#error 1
  14358. X#endif
  14359. END_OF_FILE
  14360.   if test 5863 -ne `wc -c <'mac/macstat.c'`; then
  14361.     echo shar: \"'mac/macstat.c'\" unpacked with wrong size!
  14362.   fi
  14363.   # end of 'mac/macstat.c'
  14364. fi
  14365. if test -f 'makefile' -a "${1}" != "-c" ; then 
  14366.   echo shar: Will not clobber existing file \"'makefile'\"
  14367. else
  14368.   echo shar: Extracting \"'makefile'\" \(7055 characters\)
  14369.   sed "s/^X//" >'makefile' <<'END_OF_FILE'
  14370. X# Makefile for Zip, ZipNote, ZipCloak and ZipSplit
  14371. X
  14372. X# what you can make ...
  14373. Xall:
  14374. X    @echo ''
  14375. X    @echo 'Make what?  You must say what system to make Zip for--e.g.'
  14376. X    @echo '"make bsd".  Choices: bsd, bsdold, sysv, sysv_old, sysv_386,'
  14377. X    @echo 'dnix, linux, sun, sun_gcc, next10, next, hpux, cray, cray3,'
  14378. X    @echo '3b1, att6300, zilog, scodos, aux, c120, convex, aix, minix,'
  14379. X    @echo 'isc, ultrix, dec_osf1 and xos.'
  14380. X    @echo 'See the files install.doc and zip.doc for more information.'
  14381. X    @echo ''
  14382. X
  14383. XCRYPTO =
  14384. XCLOAK =
  14385. XCRFLAG =
  14386. XMAKE = make
  14387. X#  **********************************************************************
  14388. X#  *** For encryption version, remove the # at the front of next line ***
  14389. X# MAKE = make CRYPTO="crypt.o" CLOAK="zipcloak" CRFLAG="-DCRYPT"
  14390. X
  14391. X# (to use the Gnu compiler, change cc to gcc in CC and BIND)
  14392. XCC = cc
  14393. XBIND = cc
  14394. XE =
  14395. XCPP = /usr/lib/cpp -Dunix
  14396. X
  14397. X# probably can change this to 'install' if you have it
  14398. XINSTALL = cp
  14399. X
  14400. X# target directories - where to install executables and man pages to
  14401. XBINDIR = /usr/local/bin
  14402. XMANDIR = /usr/man/manl
  14403. X
  14404. X# flags
  14405. X#   CFLAGS    flags for C compile
  14406. X#   LFLAGS1   flags after output file spec, before obj file list
  14407. X#   LFLAGS2   flags after obj file list (libraries, etc)
  14408. XCFLAGS = -O
  14409. XLFLAGS1 =
  14410. XLFLAGS2 = -s
  14411. X
  14412. X# object file lists
  14413. XOBJZ = zip.o zipfile.o zipup.o fileio.o util.o globals.o $(CRYPTO)
  14414. X
  14415. XOBJI = deflate.o trees.o bits.o
  14416. XOBJA =
  14417. XOBJU = zipfile_.o zipup_.o fileio_.o util_.o globals.o
  14418. XOBJN = zipnote.o  $(OBJU)
  14419. XOBJC = zipcloak.o $(OBJU) crypt_.o
  14420. XOBJS = zipsplit.o $(OBJU)
  14421. X
  14422. X# suffix rules
  14423. X.SUFFIXES:
  14424. X.SUFFIXES: _.o .o .c .doc .1
  14425. X.c_.o:
  14426. X    rm -f $*_.c; ln $< $*_.c
  14427. X    $(CC) $(CFLAGS) -DUTIL $(CRFLAG) -c $*_.c
  14428. X    rm -f $*_.c
  14429. X.c.o:
  14430. X    $(CC) $(CFLAGS) $(CRFLAG) -c $<
  14431. X
  14432. X.1.doc:
  14433. X    nroff -man $< | col -b | uniq > $@
  14434. X
  14435. X# rules for zip, zipnote, zipcloak, zipsplit, and zip.doc.
  14436. X$(OBJZ): zip.h ziperr.h tailor.h
  14437. X$(OBJI): zip.h ziperr.h tailor.h
  14438. X$(OBJN): zip.h ziperr.h tailor.h
  14439. X$(OBJS): zip.h ziperr.h tailor.h
  14440. X$(OBJC): zip.h ziperr.h tailor.h
  14441. X
  14442. Xmatch.o: match.s
  14443. X    $(CPP) match.s > _match.s
  14444. X    $(CC) -c _match.s
  14445. X    mv _match.o match.o
  14446. X    rm -f _match.s
  14447. X
  14448. XZIPS = zip$E zipnote$E zipsplit$E $(CLOAK)$E
  14449. X
  14450. Xzip.o zipup.o zipnote.o zipcloak.o zipsplit.o: revision.h
  14451. Xzips: $(ZIPS)
  14452. Xzipsman: zip zipnote zipsplit $(CLOAK) zip.doc
  14453. X
  14454. Xzip$E: $(OBJZ) $(OBJI) $(OBJA)
  14455. X    $(BIND) -o zip$E $(LFLAGS1) $(OBJZ) $(OBJI) $(OBJA) $(LFLAGS2)
  14456. Xzipnote$E: $(OBJN)
  14457. X    $(BIND) -o zipnote$E $(LFLAGS1) $(OBJN) $(LFLAGS2)
  14458. Xzipcloak$E: $(OBJC)
  14459. X    $(BIND) -o zipcloak$E $(LFLAGS1) $(OBJC) $(LFLAGS2)
  14460. Xzipsplit$E: $(OBJS)
  14461. X    $(BIND) -o zipsplit$E $(LFLAGS1) $(OBJS) $(LFLAGS2)
  14462. X
  14463. X# install
  14464. Xinstall:    $(ZIPS)
  14465. X    $(INSTALL) $(ZIPS) $(BINDIR)
  14466. X    $(INSTALL) zip.1 $(MANDIR)
  14467. X
  14468. X
  14469. X# These symbols, when #defined using -D have these effects on compilation:
  14470. X# ZMEM        - includes C language versions of memset(), memcpy(), and
  14471. X#          memcmp() (util.c).
  14472. X# DIRENT    - use <sys/dirent.h> and getdents() instead of <sys/dir.h>
  14473. X#          and opendir(), etc. (fileio.c).
  14474. X# NODIR        - used for 3B1, which has neither getdents() nor opendir().
  14475. X# NDIR        - use "ndir.h" instead of <sys/dir.h> (fileio.c).
  14476. X# UTIL        - select routines for utilities (note, cloak, and split).
  14477. X# PROTO        - enable function prototypes.
  14478. X# RMDIR        - remove directories using a system("rmdir ...") call.
  14479. X# CONVEX    - for Convex make target.
  14480. X# AIX        - for AIX make target.
  14481. X# CRYPT     - include the encryption code.
  14482. X# LINUX        - for linux make target.
  14483. X
  14484. X# BSD 4.3 (also Unisys 7000--AT&T System V with heavy BSD 4.2)
  14485. Xbsd:
  14486. X    $(MAKE) zips CFLAGS="-O"
  14487. X
  14488. X# BSD, but missing memset(), memcmp().
  14489. Xbsdold:
  14490. X    $(MAKE) zips CFLAGS="-O -DZMEM"
  14491. X
  14492. X# AT&T System V, Rel 3.  Also SCO, Xenix, OpenDeskTop, ETA-10P*, SGI.
  14493. Xsysv_old:
  14494. X    $(MAKE) zips CFLAGS="-O -DDIRENT"
  14495. X
  14496. X# AT&T System V, Rel 4. Also any system with readdir() and termio.
  14497. Xsysv:
  14498. X    $(MAKE) zips CFLAGS="-O -DSYSV -DTERMIO"
  14499. X
  14500. X# AT&T System V, Rel 4 for 386 (uses asm version):
  14501. Xsysv_386:
  14502. X    $(MAKE) zips CFLAGS="-O -DSYSV -DTERMIO -DASM" OBJA=match.o
  14503. X
  14504. X# DNIX 5.x: like System V but optimization is messed up.
  14505. Xdnix:
  14506. X    $(MAKE) zips CFLAGS="-DDIRENT"
  14507. X
  14508. X# Linux 0.96a with GCC 2.12, dies with <= 2.11c. The problem with
  14509. X# builtin functions still has to be investigated.
  14510. Xlinux:
  14511. X    $(MAKE) zips CFLAGS="-O -fno-builtin -DSYSV -DTERMIO -DLINUX"
  14512. X
  14513. X# Sun OS 4.x: BSD, but use getdents(). If you have gcc, use 'make sun_gcc'
  14514. X# instead since the code produced is better.
  14515. Xsun:
  14516. X    $(MAKE) zips CFLAGS="-O4 -DDIRENT"
  14517. X
  14518. X# Sun OS 4.x with gcc (bug with -s linker flag). Use -O if your version
  14519. X# of gcc does not like -O2.
  14520. Xsun_gcc:
  14521. X    $(MAKE) zips CFLAGS="-O2 -DDIRENT" CC=gcc BIND=gcc LFLAGS2=""
  14522. X    strip $(ZIPS)
  14523. X
  14524. X# NeXT 1.0: BSD, but use shared library.
  14525. Xnext10:
  14526. X    $(MAKE) zips CFLAGS="-O" LFLAGS2="-s -lsys_s"
  14527. X
  14528. X# NeXT 2.0: BSD, but use MH_OBJECT format for smaller executables.
  14529. Xnext:
  14530. X    $(MAKE) zips CFLAGS="-O" LFLAGS2="-s -object"
  14531. X
  14532. X# HPUX: System V, but use <ndir.h> and opendir(), etc.
  14533. Xhpux:
  14534. X    $(MAKE) zips CFLAGS="-O -DNDIR"
  14535. X
  14536. X# Cray Unicos 5.1.10 & 6.0.11, Standard C compiler 2.0
  14537. Xcray:
  14538. X    $(MAKE) zips CFLAGS="-O -DDIRENT" CC="scc"
  14539. X
  14540. X# Cray Unicos 6.1, Standard C compiler 3.0 (all routines except trees.c
  14541. X# may be compiled with vector3; internal compiler bug in 3.0.2.3 and
  14542. X# earlier requires vector2 for trees.c)
  14543. Xcray3:
  14544. X    $(MAKE) zips CFLAGS="-O -h vector2 -h scalar3 -DDIRENT" CC="scc"
  14545. X
  14546. X# AT&T 3B1: System V, but missing a few things.
  14547. X3b1:
  14548. X    $(MAKE) zips CFLAGS="-O -DNODIR -DRMDIR"
  14549. X
  14550. X# AT&T 6300 PLUS (don't know yet how to allocate 64K bytes):
  14551. Xatt6300:
  14552. X    $(MAKE) zips LFLAGS1="-Ml" \
  14553. X    CFLAGS="-O -Ml -DNODIR -DRMDIR -DDYN_ALLOC -DMEDIUM_MEM -DWSIZE=16384"
  14554. X
  14555. X# zilog zeus 3.21
  14556. Xzilog:
  14557. X    $(MAKE) zips CFLAGS="-O -DZMEM -DNDIR -DRMDIR" CC="scc -i" BIND="scc"
  14558. X
  14559. X# SCO 386 cross compile for MS-DOS
  14560. X# Note: zip.exe should be lzexe'd on DOS to reduce its size
  14561. Xscodos:
  14562. X    $(MAKE) zips CFLAGS="-O -Mc -dos -DNO_ASM" LFLAGS1="-Mc -dos" \
  14563. X     LFLAGS2="-F 1000" E=".exe"
  14564. X
  14565. X# A/UX:
  14566. Xaux:
  14567. X    $(MAKE) zips CFLAGS="-O -DTERMIO"
  14568. X
  14569. X# Convex C120, OS 9.0, cc v. 4.0, no vectorization.
  14570. Xc120:
  14571. X    $(MAKE) zips CFLAGS="-O1 -rl -DCONVEX"
  14572. X
  14573. X# Convex C220, OS 9.0
  14574. Xconvex:
  14575. X    $(MAKE) zips CFLAGS="-O2 -rl -DCONVEX"
  14576. X
  14577. X# AIX Version 3.1 for RISC System/6000 
  14578. Xaix:
  14579. X    $(MAKE) zips CC="c89" BIND="c89" \
  14580. X       CFLAGS="-O -D_POSIX_SOURCE -D_ALL_SOURCE -D_BSD -DAIX"
  14581. X
  14582. X# MINIX 1.5.10 with Bruce Evans 386 patches and gcc/GNU make
  14583. Xminix:
  14584. X    $(MAKE) zips CFLAGS="-O -DDIRENT -DMINIX" CC=gcc BIND=gcc
  14585. X    chmem =262144 zip
  14586. X
  14587. X# Interactive Systems Corporation System V/386, Rel 3.2--optimizer problems
  14588. Xisc:
  14589. X    $(MAKE) zips CFLAGS="-DDIRENT"
  14590. X
  14591. X# DYNIX (R) V3.0.18 (no memset() or memcmp(), rindex() instead of strrchr())
  14592. Xdynix:
  14593. X    $(MAKE) zips CFLAGS="-O -DZMEM -Dstrrchr=rindex"
  14594. X
  14595. X# Ultrix
  14596. Xultrix:
  14597. X    $(MAKE) zips CFLAGS="-O -Olimit 700"
  14598. X
  14599. X# DEC OSF/1
  14600. Xdec_osf1:
  14601. X    $(MAKE) zips CFLAGS="-O -Olimit 1000 -DOSF -D_BSD"
  14602. X
  14603. X# xos: Olivetti LSX-3005..3045 with X/OS 2.3 or 2.4
  14604. Xxos:
  14605. X    $(MAKE) zips CFLAGS="-O -DTERMIO"
  14606. X
  14607. X# clean up after making stuff and installing it
  14608. Xclean:
  14609. X    rm -f *.o
  14610. X    rm -f $(ZIPS)
  14611. X
  14612. X# This one's for Mark:
  14613. Xit:
  14614. X    $(MAKE) zipsman CFLAGS="-O -Wall -DPROTO"\
  14615. X    LFLAGS2="-s -object" VPATH="${HOME}/Unix/bin"
  14616. X
  14617. X# and this one for Jean-loup:
  14618. Xgcc_d:
  14619. X    $(MAKE) zip CFLAGS="-g -DDEBUG -DDIRENT" CC=gcc BIND=gcc LFLAGS2="-g"
  14620. X    mv zip zipd
  14621. X
  14622. X# end of Makefile
  14623. END_OF_FILE
  14624.   if test 7055 -ne `wc -c <'makefile'`; then
  14625.     echo shar: \"'makefile'\" unpacked with wrong size!
  14626.   fi
  14627.   # end of 'makefile'
  14628. fi
  14629. if test -f 'msdos/makefile.msc.UU' -a "${1}" != "-c" ; then 
  14630.   echo shar: Will not clobber existing file \"'msdos/makefile.msc.UU'\"
  14631. else
  14632.   echo shar: Extracting \"'msdos/makefile.msc.UU'\" \(5501 characters\)
  14633.   sed "s/^X//" >'msdos/makefile.msc.UU' <<'END_OF_FILE'
  14634. Xbegin 666 msdos/makefile.msc
  14635. XM(R!-86ME9FEL92!F;W(@6FEP+"!::7!#;&]A:RP@6FEP3F]T92!A;F0@6FEP
  14636. XM4W!L:70@9F]R#0HC($UI8W)O<V]F="!#(#4N,2!O<B V+C N#0H-"B,@5&\@
  14637. XM=7-E+"!D;R B;6%K92!M86ME9FEL92YM<V,B#0H-"B,@061D("U$4TU!3$Q?
  14638. XM345-(&]R("U$345$255-7TU%32!T;R!#1DQ!1U,@:68@>6]U('=I<V@@=&\@
  14639. XM<F5D=6-E('1H92!M96UO<GD-"B,@<F5Q=6ER96UE;G1S+B!!9&0@+41.3U]!
  14640. XM4TT@=&\@0T9,04=3(&%N9"!R96UO=F4@;6%T8V@N;V)J(&9R;VT@3T)*22!I
  14641. XM9@T*(R!Y;W4@9&\@;F]T(&AA=F4@;6%S;2X-"@T*0U)94%1//0T*0TQ/04L]
  14642. XM#0I#4D9,04<]#0H-"B,@("HJ*B!&;W(@96YC<GEP=&EO;B!V97)S:6]N+"!R
  14643. XM96UO=F4@=&AE(",@870@=&AE(&9R;VYT(&]F(&YE>'0@,R!L:6YE<R J*BH-
  14644. XM"B-#4EE05$\]8W)Y<'0N;V)J#0HC0TQ/04L]>FEP8VQO86LN97AE#0HC0U)&
  14645. XM3$%'/2U$0U)94%0-"@T*(R M+2TM+2TM+2TM+2TM($UI8W)O<V]F="!#(#4N
  14646. XM,2!O<B V+C @+2TM+2TM+2TM+2TM+0T*34]$14P]+4%##0I&4#T-"D-&3$%'
  14647. XM4STM5S,@+4]X("UN;VQO9V\@)"A-3T1%3"D@)"A&4"D@)"A#4D9,04<I#0I3
  14648. XM4$5#1DQ!1U,]+5<S("U/86EC=" M1W,@+6YO;&]G;R D*$U/1$5,*2 D*$90
  14649. XM*2 D*$-21DQ!1RD-"E5424Q&3$%'4STM1%5424P@)"A#1DQ!1U,I("U&;PT*
  14650. XM0T,]8VP-"DQ$/6QI;FL-"DQ$1DQ!1U,]+V4O<W0Z,'@Q,# P#0HC(" @("!)
  14651. XM9B!Y;W4@=7-E(&QZ97AE(&%S(')E8V]M;65N9&5D+"!R96UO=F4@+V4@9G)O
  14652. XM;2!,1$9,04=3#0I!4SUM87-M#0HC(" @("!&;W(@35-#(#8N,"P@=7-E.B!!
  14653. XM4SUM;" -"D%31DQ!1U,]+6UL("UT#0HC($%D9" M1$193E]!3$Q/0R!T;R!!
  14654. XM4T9,04=3(&EF('EO=2!H879E(&1E9FEN960@:70@:6X@=&%I;&]R+F@@;W(@
  14655. XM0T9,04=3#0H-"B,@+2TM+2TM+2TM+2TM+2!#;VUM;VX@9&5C;&%R871I;VYS
  14656. XM.@T*4U1225 ]<F5M#0HC(" @($EF('EO=2!D;VXG="!H879E(&QZ97AE+"!G
  14657. XM970@:70N(%1H96X@9&5F:6YE.@T*(U-44DE0/6QZ97AE#0HC(" @($]R(&EF
  14658. XM('EO=2=V92!R96=I<W1E<F5D(%!+3$E412P@=&AE;B!D969I;F4Z#0HC4U12
  14659. XM25 ]<&ML:71E#0HC(" @(%1H:7,@;6%K97,@82!B:6<@9&EF9F5R96YC92!I
  14660. XM;B N97AE('-I>F4@*&%N9"!P;W-S:6)L>2!L;V%D('1I;64I#0H-"B,@+2TM
  14661. XM+2TM+2TM+2TM+2!5<V5D(&)Y(&EN<W1A;&P@<G5L90T*(R!S970@0DE.('1O
  14662. XM('1H92!D:7)E8W1O<GD@>6]U('=A;G0@=&\@:6YS=&%L;"!T:&4@97AE8W5T
  14663. XM86)L97,@=&\-"D))3B ](&,Z7'5T:6P-"@T*(R!V87)I86)L97,-"D]"2EH@
  14664. XM/2!Z:7 N;V)J('II<&9I;&4N;V)J('II<'5P+F]B:B!F:6QE:6\N;V)J('5T
  14665. XM:6PN;V)J(&=L;V)A;',N;V)J("0H0U)94%1/*0T*#0I/0DI)(#T@9&5F;&%T
  14666. XM92YO8FH@=')E97,N;V)J(&)I=',N;V)J(&UA=&-H+F]B:@T*(R!R96UO=F4@
  14667. XM;6%T8V@N;V)J(&EF('EO=2!D;R!N;W0@:&%V92!M87-M#0H-"D]"2E4@/2!Z
  14668. XM:7!F:6QE7RYO8FH@>FEP=7!?+F]B:B!F:6QE:6]?+F]B:B!U=&EL7RYO8FH@
  14669. XM9VQO8F%L<RYO8FH-"D]"2DX@/2!Z:7!N;W1E+F]B:B @)"A/0DI5*0T*3T)*
  14670. XM0R ]('II<&-L;V%K+F]B:B D*$]"2E4I(&-R>7!T7RYO8FH-"D]"2E,@/2!Z
  14671. XM:7!S<&QI="YO8FH@)"A/0DI5*0T*#0I:25!3(#T@>FEP+F5X92!Z:7!N;W1E
  14672. XM+F5X92!Z:7!S<&QI="YE>&4@)"A#3$]!2RD-"@T*>FEP<SH))"A:25!3*0T*
  14673. XM#0IZ:7 N;V)J.@EZ:7 N:"!Z:7!E<G(N:"!T86EL;W(N:"!R979I<VEO;BYH
  14674. XM('II<"YC#0H))"A#0RD@+6,@)"A#1DQ!1U,I("0J+F,-"@T*(R!-4T,@-2XQ
  14675. XM(&=E;F5R871E<R!B860@8V]D92!O;B!Z:7!F:6QE('=I=&@@+4]X#0IZ:7!F
  14676. XM:6QE+F]B:CH)>FEP+F@@>FEP97)R+F@@=&%I;&]R+F@@>FEP9FEL92YC#0H)
  14677. XM)"A#0RD@+6,@)"A34$5#1DQ!1U,I("0J+F,-"@T*>FEP=7 N;V)J.@EZ:7 N
  14678. XM:"!Z:7!E<G(N:"!T86EL;W(N:"!R979I<VEO;BYH('II<'5P+F,-"@DD*$-#
  14679. XM*2 M8R D*$-&3$%'4RD@)"HN8PT*#0IF:6QE:6\N;V)J.@EZ:7 N:"!Z:7!E
  14680. XM<G(N:"!T86EL;W(N:"!F:6QE:6\N8PT*"20H0T,I("UC("0H0T9,04=3*2 D
  14681. XM*BYC#0H-"G5T:6PN;V)J.@EZ:7 N:"!Z:7!E<G(N:"!T86EL;W(N:"!U=&EL
  14682. XM+F,-"@DD*$-#*2 M8R D*$-&3$%'4RD@)"HN8PT*#0IG;&]B86QS+F]B:CH)
  14683. XM>FEP+F@@>FEP97)R+F@@=&%I;&]R+F@@9VQO8F%L<RYC#0H))"A#0RD@+6,@
  14684. XM)"A#1DQ!1U,I("0J+F,-"@T*9&5F;&%T92YO8FHZ"7II<"YH('II<&5R<BYH
  14685. XM('1A:6QO<BYH(&1E9FQA=&4N8PT*"20H0T,I("UC("0H0T9,04=3*2 D*BYC
  14686. XM#0H-"G1R965S+F]B:CH)>FEP+F@@>FEP97)R+F@@=&%I;&]R+F@@=')E97,N
  14687. XM8PT*"20H0T,I("UC("0H0T9,04=3*2 D*BYC#0H-"F)I=',N;V)J.@EZ:7 N
  14688. XM:"!Z:7!E<G(N:"!T86EL;W(N:"!B:71S+F,-"@DD*$-#*2 M8R D*$-&3$%'
  14689. XM4RD@)"HN8PT*#0IC<GEP="YO8FHZ"7II<"YH('II<&5R<BYH('1A:6QO<BYH
  14690. XM(&-R>7!T+F,-"@DD*$-#*2 M8R D*$-&3$%'4RD@)"HN8PT*#0IZ:7!C;&]A
  14691. XM:RYO8FHZ"7II<"YH('II<&5R<BYH('1A:6QO<BYH(')E=FES:6]N+F@@>FEP
  14692. XM8VQO86LN8PT*"20H0T,I("UC("0H0T9,04=3*2 D*BYC#0H-"GII<&YO=&4N
  14693. XM;V)J.@EZ:7 N:"!Z:7!E<G(N:"!T86EL;W(N:"!R979I<VEO;BYH('II<&YO
  14694. XM=&4N8PT*"20H0T,I("UC("0H0T9,04=3*2 D*BYC#0H-"B,@35-#(#4N,2!D
  14695. XM:65S(&]N('II<'-P;&ET('=I=&@@+4]X#0IZ:7!S<&QI="YO8FHZ"7II<'-P
  14696. XM;&ET+F,@>FEP+F@@>FEP97)R+F@@=&%I;&]R+F@@<F5V:7-I;VXN: T*"20H
  14697. XM0T,I("UC("0H4U!%0T9,04=3*2 D*BYC#0H-"B,@35-#(#4N,2!G96YE<F%T
  14698. XM97,@8F%D(&-O9&4@;VX@>FEP9FEL92!W:71H("U/> T*>FEP9FEL95\N;V)J
  14699. XM.@EZ:7!F:6QE+F,@>FEP+F@@>FEP97)R+F@@=&%I;&]R+F@-"@DD*$-#*2 M
  14700. XM8R D*%-014-&3$%'4RD@+4155$E,("U&;R1 ('II<&9I;&4N8PT*#0IZ:7!U
  14701. XM<%\N;V)J.@EZ:7!U<"YC('II<"YH('II<&5R<BYH('1A:6QO<BYH#0H))"A#
  14702. XM0RD@+6,@)"A55$E,1DQ!1U,I)$ @>FEP=7 N8PT*#0IF:6QE:6]?+F]B:CH)
  14703. XM9FEL96EO+F,@>FEP+F@@>FEP97)R+F@@=&%I;&]R+F@-"@DD*$-#*2 M8R D
  14704. XM*%5424Q&3$%'4RDD0"!F:6QE:6\N8PT*#0IU=&EL7RYO8FHZ"75T:6PN8R!Z
  14705. XM:7 N:"!Z:7!E<G(N:"!T86EL;W(N: T*"20H0T,I("UC("0H551)3$9,04=3
  14706. XM*21 ('5T:6PN8PT*#0IC<GEP=%\N;V)J.@EC<GEP="YC('II<"YH#0H))"A#
  14707. XM0RD@+6,@)"A55$E,1DQ!1U,I)$ @8W)Y<'0N8PT*#0IM871C:"YO8FHZ"6UA
  14708. XM=&-H+F%S;0T*"20H05,I("0H05-&3$%'4RD@;6%T8V@[#0H-"B,@=V4@;75S
  14709. XM="!C=70@=&AE(&-O;6UA;F0@;&EN92!T;R!F:70@:6X@=&AE($U3+T1/4R Q
  14710. XM,C@@8GET92!L:6UI=#H-"GII<"YE>&4Z("0H3T)*6BD@)"A/0DI)*0T*"65C
  14711. XM:&\@)"A/0DI:*2L@/B!Z:7 N<G-P#0H)96-H;R D*$]"2DDI.R ^/B!Z:7 N
  14712. XM<G-P#0H))"A,1"D@)"A,1$9,04=3*2! >FEP+G)S< T*"61E;"!Z:7 N<G-P
  14713. XM#0H))"A35%))4"D@>FEP+F5X90T*#0IZ:7!C;&]A:RYE>&4Z("0H3T)*0RD-
  14714. XM"@EE8VAO("0H3T)*0RD[(#X@>FEP8RYR<W -"@DD*$Q$*2 D*$Q$1DQ!1U,I
  14715. XM($!Z:7!C+G)S< T*"61E;"!Z:7!C+G)S< T*"20H4U1225 I('II<&-L;V%K
  14716. XM+F5X90T*#0IZ:7!N;W1E+F5X93H@)"A/0DI.*0T*"65C:&\@)"A/0DI.*3L@
  14717. XM/B!Z:7!N+G)S< T*"20H3$0I("0H3$1&3$%'4RD@0'II<&XN<G-P#0H)9&5L
  14718. XM('II<&XN<G-P#0H))"A35%))4"D@>FEP;F]T92YE>&4-"@T*>FEP<W!L:70N
  14719. XM97AE.B D*$]"2E,I#0H)96-H;R D*$]"2E,I.R ^('II<',N<G-P#0H))"A,
  14720. XM1"D@)"A,1$9,04=3*2! >FEP<RYR<W -"@ED96P@>FEP<RYR<W -"@DD*%-4
  14721. XM4DE0*2!Z:7!S<&QI="YE>&4-"@T*:6YS=&%L;#H))"A:25!3*0T*"6-O<'D@
  14722. XM+V(@*BYE>&4@)"A"24XI#0H-"F-L96%N.@T*"61E;" J+F]B:@T*"61E;" J
  14723. X&+F5X90T*
  14724. Xend
  14725. END_OF_FILE
  14726.   if test 5501 -ne `wc -c <'msdos/makefile.msc.UU'`; then
  14727.     echo shar: \"'msdos/makefile.msc.UU'\" unpacked with wrong size!
  14728.   else
  14729.     echo shar: Uudecoding \"'msdos/makefile.msc'\" \(3966 characters\)
  14730.     cat msdos/makefile.msc.UU | uudecode
  14731.     if test 3966 -ne `wc -c <'msdos/makefile.msc'`; then
  14732.       echo shar: \"'msdos/makefile.msc'\" uudecoded with wrong size!
  14733.     else
  14734.       rm msdos/makefile.msc.UU
  14735.     fi
  14736.   fi
  14737.   # end of 'msdos/makefile.msc.UU'
  14738. fi
  14739. if test -f 'msdos/match.asm' -a "${1}" != "-c" ; then 
  14740.   echo shar: Will not clobber existing file \"'msdos/match.asm'\"
  14741. else
  14742.   echo shar: Extracting \"'msdos/match.asm'\" \(7753 characters\)
  14743.   sed "s/^X//" >'msdos/match.asm' <<'END_OF_FILE'
  14744. X;
  14745. X; Copyright (C) 1990-1992 Mark Adler, Richard B. Wales, and Jean-loup Gailly.
  14746. X; Permission is granted to any individual or institution to use, copy, or
  14747. X; redistribute this software so long as all of the original files are included
  14748. X; unmodified, that it is not sold for profit, and that this copyright notice
  14749. X; is retained.
  14750. X;
  14751. X; match.asm by Jean-loup Gailly.
  14752. X
  14753. X; match.asm, optimized version of longest_match() in deflate.c
  14754. X; Must be assembled with masm -ml. To be used only with C compact model.
  14755. X; (For large model, follow the instructions given below.)
  14756. X; This file is only optional. If you don't have masm or tasm, use the
  14757. X; C version (add -DNO_ASM to CFLAGS in makefile.msc and remove match.obj
  14758. X; from OBJI). If you have reduced WSIZE in zip.h, then change its value
  14759. X; below.
  14760. X;
  14761. X; Turbo C 2.0 does not support static allocation of more than 64K bytes per
  14762. X; file, and does not have SS == DS. So TC and BC++ users must use:
  14763. X;   tasm -ml -DDYN_ALLOC -DSS_NEQ_DS match;
  14764. X;
  14765. X; To simplify the code, the option -DDYN_ALLOC is supported for OS/2
  14766. X; only if the arrays are guaranteed to have zero offset (allocated by
  14767. X; halloc). We also require SS==DS. This is satisfied for MSC but not Turbo C.
  14768. X
  14769. X        name    match
  14770. X
  14771. Xifndef DYN_ALLOC
  14772. X        extrn   _prev         : word
  14773. X        extrn   _window       : byte
  14774. X        prev    equ  _prev    ; offset part
  14775. X        window  equ  _window
  14776. Xendif
  14777. X
  14778. X_DATA    segment  word public 'DATA'
  14779. X        extrn   _match_start  : word
  14780. X        extrn   _prev_length  : word
  14781. X        extrn   _good_match   : word
  14782. X        extrn   _strstart     : word
  14783. X        extrn   _max_chain_length : word
  14784. Xifdef DYN_ALLOC
  14785. X        extrn   _prev         : word
  14786. X        extrn   _window       : word
  14787. X        prev    equ 0         ; offset forced to zero
  14788. X        window  equ 0
  14789. X        window_seg equ _window[2]
  14790. X    window_off equ 0
  14791. Xelse
  14792. X    wseg    dw seg _window
  14793. X        window_seg equ wseg
  14794. X    window_off equ offset _window
  14795. Xendif
  14796. X_DATA    ends
  14797. X
  14798. XDGROUP  group _DATA
  14799. X
  14800. X_TEXT   segment word public 'CODE'
  14801. X        assume  cs: _TEXT, ds: DGROUP
  14802. X
  14803. X    public _match_init
  14804. X        public _longest_match
  14805. X
  14806. X    MIN_MATCH     equ 3
  14807. X        MAX_MATCH     equ 258
  14808. X    WSIZE         equ 32768        ; keep in sync with zip.h !
  14809. X    MIN_LOOKAHEAD equ (MAX_MATCH+MIN_MATCH+1)
  14810. X    MAX_DIST      equ (WSIZE-MIN_LOOKAHEAD)
  14811. X
  14812. Xprev_ptr    dw  seg _prev        ; pointer to the prev array
  14813. Xifdef SS_NEQ_DS
  14814. X    match_start dw  0            ; copy of _match_start if SS != DS
  14815. Xendif
  14816. X
  14817. X; initialize or check the variables used in match.asm.
  14818. X
  14819. X_match_init proc near            ; 'proc far' for large model
  14820. Xifdef SS_NEQ_DS
  14821. X        ma_start equ cs:match_start    ; does not work on OS/2
  14822. Xelse
  14823. X    assume ss: DGROUP
  14824. X        ma_start equ ss:_match_start
  14825. X        mov     ax,ds
  14826. X        mov     bx,ss
  14827. X        cmp     ax,bx                   ; SS == DS?
  14828. X        jne     error
  14829. Xendif
  14830. Xifdef DYN_ALLOC
  14831. X    cmp    _prev[0],0        ; verify zero offset
  14832. X    jne    error
  14833. X    cmp    _window[0],0
  14834. X    jne    error
  14835. X  ifdef SS_NEQ_DS
  14836. X    mov    ax,_prev[2]        ; segment value
  14837. X    mov     cs:prev_ptr,ax        ; ugly write to code, crash on OS/2
  14838. X        prev_seg  equ cs:prev_ptr
  14839. X  else
  14840. X        prev_seg  equ ss:_prev[2]    ; works on OS/2 if SS == DS
  14841. X  endif
  14842. Xelse
  14843. X        prev_seg  equ cs:prev_ptr
  14844. Xendif
  14845. X    ret
  14846. X    extrn   _exit : near        ; 'far' for large model
  14847. Xerror:  call    _exit
  14848. X
  14849. X_match_init endp
  14850. X
  14851. X; -----------------------------------------------------------------------
  14852. X; Set match_start to the longest match starting at the given string and
  14853. X; return its length. Matches shorter or equal to prev_length are discarded,
  14854. X; in which case the result is equal to prev_length and match_start is
  14855. X; garbage.
  14856. X; IN assertions: cur_match is the head of the hash chain for the current
  14857. X;   string (strstart) and its distance is <= MAX_DIST, and prev_length >= 1
  14858. X
  14859. X; int longest_match(cur_match)
  14860. X
  14861. X_longest_match  proc near         ; 'proc far' for large model
  14862. X        push    bp
  14863. X        mov     bp,sp
  14864. X        push    di
  14865. X    push    si
  14866. X    push    ds
  14867. X
  14868. X        cur_match    equ word ptr [bp+4] ; [bp+6] for large model
  14869. X
  14870. X;       window         equ es:window (es:0 for DYN_ALLOC)
  14871. X;       prev         equ ds:prev
  14872. X;       match        equ es:si
  14873. X;       scan         equ es:di
  14874. X;       chain_length equ bp
  14875. X;       best_len     equ bx
  14876. X;       limit        equ dx
  14877. X
  14878. X    mov    si,cur_match            ; use bp before it is destroyed
  14879. X        mov     bp,_max_chain_length    ; chain_length = max_chain_length
  14880. X    mov    di,_strstart
  14881. X    mov    dx,di
  14882. X    sub    dx,MAX_DIST             ; limit = strstart-MAX_DIST
  14883. X    jae    limit_ok
  14884. X    sub    dx,dx            ; limit = NIL
  14885. Xlimit_ok:
  14886. X        add     di,2+window_off         ; di = offset(window + strstart + 2)
  14887. X        mov     bx,_prev_length         ; best_len = prev_length
  14888. X    mov     es,window_seg
  14889. X        mov     ax,es:[bx+di-3]         ; ax = scan[best_len-1..best_len]
  14890. X        mov     cx,es:[di-2]            ; cx = scan[0..1]
  14891. X    cmp    bx,_good_match        ; do we have a good match already?
  14892. X        mov     ds,prev_seg            ; (does not destroy the flags)
  14893. X        assume  ds: nothing
  14894. X        jb      do_scan            ; good match?
  14895. X    shr    bp,1            ; chain_length >>= 2
  14896. X    shr    bp,1
  14897. X        jmp     short do_scan
  14898. X
  14899. X        even                            ; align destination of branch
  14900. Xlong_loop:
  14901. X; at this point, ds:di == scan+2, ds:si == cur_match
  14902. X        mov     ax,[bx+di-3]            ; ax = scan[best_len-1..best_len]
  14903. X        mov     cx,[di-2]               ; cx = scan[0..1]
  14904. X        mov     ds,prev_seg            ; reset ds to address the prev array
  14905. Xshort_loop:
  14906. X        dec     bp                      ; --chain_length
  14907. X        jz      the_end
  14908. X; at this point, di == scan+2, si = cur_match,
  14909. X; ax = scan[best_len-1..best_len] and cx = scan[0..1]
  14910. Xif (WSIZE-32768)
  14911. X        and     si,WSIZE-1              ; not needed if WSIZE=32768
  14912. Xendif
  14913. X        shl     si,1                    ; cur_match as word index
  14914. X        mov     si,prev[si]             ; cur_match = prev[cur_match]
  14915. X        cmp     si,dx            ; cur_match <= limit ?
  14916. X        jbe     the_end
  14917. Xdo_scan:
  14918. X        cmp     ax,word ptr es:window[bx+si-1] ; check match at best_len-1
  14919. X        jne     short_loop
  14920. X        cmp     cx,word ptr es:window[si]      ; check min_match_length match
  14921. X        jne     short_loop
  14922. X
  14923. X        lea     si,window[si+2]         ; si = match
  14924. X        mov     ax,di                   ; ax = scan+2
  14925. X        mov     cx,es
  14926. X        mov     ds,cx            ; ds = es = window
  14927. X        mov     cx,(MAX_MATCH-2)/2      ; scan for at most MAX_MATCH bytes
  14928. X        repe    cmpsw                   ; loop until mismatch
  14929. X        je      maxmatch                ; match of length MAX_MATCH?
  14930. Xmismatch:
  14931. X        mov     cl,[di-2]               ; mismatch on first or second byte?
  14932. X        sub     cl,[si-2]               ; cl = 0 if first bytes equal
  14933. X        xchg    ax,di                   ; di = scan+2, ax = end of scan
  14934. X        sub     ax,di                   ; ax = len
  14935. X    sub    si,ax            ; si = cur_match + 2 + offset(window)
  14936. X    sub    si,2+window_off         ; si = cur_match
  14937. X        sub     cl,1                    ; set carry if cl == 0 (can't use DEC)
  14938. X        adc     ax,0                    ; ax = carry ? len+1 : len
  14939. X        cmp     ax,bx                   ; len > best_len ?
  14940. X        jle     long_loop
  14941. X        mov     ma_start,si             ; match_start = cur_match
  14942. X        mov     bx,ax                   ; bx = best_len = len
  14943. X        cmp     ax,MAX_MATCH            ; len >= MAX_MATCH ?
  14944. X        jl      long_loop
  14945. Xthe_end:
  14946. X    pop    ds
  14947. X        assume  ds: DGROUP
  14948. Xifdef SS_NEQ_DS
  14949. X    mov    ax,ma_start        ; garbage if no match found
  14950. X    mov    ds:_match_start,ax
  14951. Xendif
  14952. X        pop     si
  14953. X        pop     di
  14954. X        pop     bp
  14955. X        mov     ax,bx                   ; result = ax = best_len
  14956. X        ret
  14957. Xmaxmatch:                               ; come here if maximum match
  14958. X        cmpsb                           ; increment si and di
  14959. X        jmp     mismatch                ; force match_length = MAX_LENGTH
  14960. X        
  14961. X_longest_match  endp
  14962. X
  14963. X_TEXT   ends
  14964. Xend
  14965. END_OF_FILE
  14966.   if test 7753 -ne `wc -c <'msdos/match.asm'`; then
  14967.     echo shar: \"'msdos/match.asm'\" unpacked with wrong size!
  14968.   fi
  14969.   # end of 'msdos/match.asm'
  14970. fi
  14971. if test -f 'os2/match32.asm.UU' -a "${1}" != "-c" ; then 
  14972.   echo shar: Will not clobber existing file \"'os2/match32.asm.UU'\"
  14973. else
  14974.   echo shar: Extracting \"'os2/match32.asm.UU'\" \(8134 characters\)
  14975.   sed "s/^X//" >'os2/match32.asm.UU' <<'END_OF_FILE'
  14976. Xbegin 666 os2/match32.asm
  14977. XM.PT*.R!#;W!Y<FEG:'0@*$,I(#$Y.3 M,3DY,B!-87)K($%D;&5R+"!2:6-H
  14978. XM87)D($(N(%=A;&5S+"!*96%N+6QO=7 @1V%I;&QY+ T*.R!+86D@57=E(%)O
  14979. XM;6UE;"!A;F0@26=O<B!-86YD<FEC:&5N:V\N#0H[(%!E<FUI<W-I;VX@:7,@
  14980. XM9W)A;G1E9"!T;R!A;GD@:6YD:79I9'5A;"!O<B!I;G-T:71U=&EO;B!T;R!U
  14981. XM<V4L(&-O<'DL(&]R#0H[(')E9&ES=')I8G5T92!T:&ES('-O9G1W87)E('-O
  14982. XM(&QO;F<@87,@86QL(&]F('1H92!O<FEG:6YA;"!F:6QE<R!A<F4@:6YC;'5D
  14983. XM960-"CL@=6YM;V1I9FEE9"P@=&AA="!I="!I<R!N;W0@<V]L9"!F;W(@<')O
  14984. XM9FET+"!A;F0@=&AA="!T:&ES(&-O<'ER:6=H="!N;W1I8V4-"CL@:7,@<F5T
  14985. XM86EN960N#0H[#0H[(&UA=&-H,S(N87-M(&)Y($IE86XM;&]U<"!'86EL;'DN
  14986. XM#0H-"CL@;6%T8V@S,BYA<VTL(&]P=&EM:7IE9"!V97)S:6]N(&]F(&QO;F=E
  14987. XM<W1?;6%T8V@H*2!I;B!D969L871E+F,-"CL@5&\@8F4@=7-E9"!O;FQY('=I
  14988. XM=&@@,S(@8FET(&9L870@;6]D96PN(%1O('-I;7!L:69Y('1H92!C;V1E+"!T
  14989. XM:&4@;W!T:6]N#0H[("U$1%E.7T%,3$]#(&ES(&YO="!S=7!P;W)T960N#0H[
  14990. XM(%1H:7,@9FEL92!I<R!O;FQY(&]P=&EO;F%L+B!)9B!Y;W4@9&]N)W0@:&%V
  14991. XM92!A;B!A<W-E;6)L97(L('5S92!T:&4-"CL@0R!V97)S:6]N("AA9&0@+41.
  14992. XM3U]!4TT@=&\@0T9,04=3(&EN(&UA:V5F:6QE(&%N9"!R96UO=F4@;6%T8V@N
  14993. XM;PT*.R!F<F]M($]"2DDI+B!)9B!Y;W4@:&%V92!R961U8V5D(%=325I%(&EN
  14994. XM('II<"YH+"!T:&5N(&-H86YG92!I=',@=F%L=64-"CL@8F5L;W<N#0H[(" @
  14995. XM(" @(" @(" @(" @*BHJ(%=A<FYI;F<Z('1H:7,@9FEL92!I<R!S=&EL;"!U
  14996. XM;G1E<W1E9" J*BH-"B @(" @(" @+C,X-@T*#0H@(" @(" @(&YA;64@(" @
  14997. XM;6%T8V@-"@T*7T)34R @("!S96=M96YT("!D=V]R9"!54T4S,B!P=6)L:6,@
  14998. XM)T)34R<-"B @(" @(" @97AT<FX@("!?;6%T8VA?<W1A<G0@(#H@9'=O<F0-
  14999. XM"B @(" @(" @97AT<FX@("!?<')E=E]L96YG=&@@(#H@9'=O<F0-"B @(" @
  15000. XM(" @97AT<FX@("!?9V]O9%]M871C:" @(#H@9'=O<F0-"B @(" @(" @97AT
  15001. XM<FX@("!?<W1R<W1A<G0@(" @(#H@9'=O<F0-"B @(" @(" @97AT<FX@("!?
  15002. XM;6%X7V-H86EN7VQE;F=T:" Z(&1W;W)D#0H@(" @(" @(&5X=')N(" @7W!R
  15003. XM978@(" @(" @(" Z('=O<F0-"B @(" @(" @97AT<FX@("!?=VEN9&]W(" @
  15004. XM(" @(#H@8GET90T*7T)34R @("!E;F1S#0H-"D1'4D]54" @9W)O=7 @7T)3
  15005. XM4PT*#0I?5$585" @('-E9VUE;G0@9'=O<F0@55-%,S(@<'5B;&EC("=#3T1%
  15006. XM)PT*(" @(" @("!A<W-U;64@(&-S.B!?5$585"P@9',Z($1'4D]54"P@<W,Z
  15007. XM($1'4D]54 T*#0H)<'5B;&EC(&UA=&-H7VEN:71?#0H@(" @(" @('!U8FQI
  15008. XM8R!L;VYG97-T7VUA=&-H7PT*#0H)34E.7TU!5$-((" @("!E<74@,PT*(" @
  15009. XM(" @("!-05A?34%40T@@(" @(&5Q=2 R-3@-"@E74TE:12 @(" @(" @(&5Q
  15010. XM=2 S,C<V. D).R!K965P(&EN('-Y;F,@=VET:"!Z:7 N:" A#0H)34E.7TQ/
  15011. XM3TM!2$5!1"!E<74@*$U!6%]-051#2"M-24Y?34%40T@K,2D-"@E-05A?1$E3
  15012. XM5" @(" @(&5Q=2 H5U-)6D4M34E.7TQ/3TM!2$5!1"D-"@T*.R!I;FET:6%L
  15013. XM:7IE(&]R(&-H96-K('1H92!V87)I86)L97,@=7-E9"!I;B!M871C:"YA<VTN
  15014. XM#0H-"FUA=&-H7VEN:71?('!R;V,@;F5A<@T*"7)E= T*;6%T8VA?:6YI=%\@
  15015. XM96YD< T*#0H[("TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM
  15016. XM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM#0H[(%-E="!M
  15017. XM871C:%]S=&%R="!T;R!T:&4@;&]N9V5S="!M871C:"!S=&%R=&EN9R!A="!T
  15018. XM:&4@9VEV96X@<W1R:6YG(&%N9 T*.R!R971U<FX@:71S(&QE;F=T:"X@36%T
  15019. XM8VAE<R!S:&]R=&5R(&]R(&5Q=6%L('1O('!R979?;&5N9W1H(&%R92!D:7-C
  15020. XM87)D960L#0H[(&EN('=H:6-H(&-A<V4@=&AE(')E<W5L="!I<R!E<75A;"!T
  15021. XM;R!P<F5V7VQE;F=T:"!A;F0@;6%T8VA?<W1A<G0@:7,-"CL@9V%R8F%G92X-
  15022. XM"CL@24X@87-S97)T:6]N<SH@8W5R7VUA=&-H(&ES('1H92!H96%D(&]F('1H
  15023. XM92!H87-H(&-H86EN(&9O<B!T:&4@8W5R<F5N= T*.R @('-T<FEN9R H<W1R
  15024. XM<W1A<G0I(&%N9"!I=',@9&ES=&%N8V4@:7,@/#T@34%87T1)4U0L(&%N9"!P
  15025. XM<F5V7VQE;F=T:" ^/2 Q#0H-"CL@:6YT(&QO;F=E<W1?;6%T8V@H8W5R7VUA
  15026. XM=&-H*0T*#0IL;VYG97-T7VUA=&-H7R!P<F]C(&YE87(-"@T*(" @(" @("!C
  15027. XM=7)?;6%T8V@@(" @97%U(&1W;W)D('!T<B!;97-P*S(P70T*(" @(" @(" [
  15028. XM(')E='5R;B!A9&1R97-S(" @(" @(" @(" @(" @(#L@97-P*S$V#0H@(" @
  15029. XM(" @('!U<V@@(" @96)P(" @(" @(" @(" @(" @(" @(" @.R!E<W K,3(-
  15030. XM"B @(" @(" @<'5S:" @("!E9&D@(" @(" @(" @(" @(" @(" @(" [(&5S
  15031. XM<"LX#0H)<'5S: EE<VD@(" @(" @(" @(" @(" @(" @(" [(&5S<"LT#0H)
  15032. XM<'5S: EE8G@@(" @(" @(" @(" @(" @(" @(" [(&5S< T*#0H[(" @(" @
  15033. XM(&UA=&-H(" @(" @("!E<74@97-I#0H[(" @(" @('-C86X@(" @(" @("!E
  15034. XM<74@961I#0H[(" @(" @(&-H86EN7VQE;F=T:"!E<74@96)P#0H[(" @(" @
  15035. XM(&)E<W1?;&5N(" @("!E<74@96)X#0H[(" @(" @(&QI;6ET(" @(" @("!E
  15036. XM<74@961X#0H-"@EM;W8)97-I+&-U<E]M871C: T*(" @(" @("!M;W8@(" @
  15037. XM(&5B<"Q?;6%X7V-H86EN7VQE;F=T:" @(#L@8VAA:6Y?;&5N9W1H(#T@;6%X
  15038. XM7V-H86EN7VQE;F=T: T*"6UO=@EE9&DL7W-T<G-T87)T#0H);6]V"65D>"QE
  15039. XM9&D-"@ES=6()961X+$U!6%]$25-4(" @(" @(" @(" @.R!L:6UI=" ]('-T
  15040. XM<G-T87)T+4U!6%]$25-4#0H):F%E"7-H;W)T(&QI;6ET7V]K#0H)<W5B"65D
  15041. XM>"QE9'@)"0D[(&QI;6ET(#T@3DE,#0IL:6UI=%]O:SH-"B @(" @(" @861D
  15042. XM(" @("!E9&DL,BMO9F9S970@7W=I;F1O=R @(" [(&5D:2 ](&]F9G-E="AW
  15043. XM:6YD;W<@*R!S=')S=&%R=" K(#(I#0H@(" @(" @(&UO=B @(" @96)X+%]P
  15044. XM<F5V7VQE;F=T:" @(" @(" @.R!B97-T7VQE;B ]('!R979?;&5N9W1H#0H@
  15045. XM(" @(" @(&UO=B @(" @87@L6V5B>"ME9&DM,UT@(" @(" @(" @.R!A>" ]
  15046. XM('-C86Y;8F5S=%]L96XM,2XN8F5S=%]L96Y=#0H@(" @(" @(&UO=B @(" @
  15047. XM8W@L6V5D:2TR72 @(" @(" @(" @(" @.R!C>" ]('-C86Y;,"XN,5T-"@EC
  15048. XM;7 )96)X+%]G;V]D7VUA=&-H( D[(&1O('=E(&AA=F4@82!G;V]D(&UA=&-H
  15049. XM(&%L<F5A9'D_#0H@(" @(" @(&IB(" @(" @9&]?<V-A;@T*"7-H<@EE8G L
  15050. XM,@D)"3L@8VAA:6Y?;&5N9W1H(#X^/2 R#0H@(" @(" @(&IM<" @(" @<VAO
  15051. XM<G0@9&]?<V-A;@T*#0H@(" @(" @(&%L:6=N(" @-" @(" @(" @(" @(" @
  15052. XM(" @(" @(" @.R!A;&EG;B!D97-T:6YA=&EO;B!O9B!B<F%N8V@-"FQO;F=?
  15053. XM;&]O<#H-"CL@870@=&AI<R!P;VEN="P@961I(#T]('-C86XK,BP@97-I(#T]
  15054. XM(&-U<E]M871C: T*(" @(" @("!M;W8@(" @(&%X+%ME8G@K961I+3-=(" @
  15055. XM(" @(" @(#L@87@@/2!S8V%N6V)E<W1?;&5N+3$N+F)E<W1?;&5N70T*(" @
  15056. XM(" @("!M;W8@(" @(&-X+%ME9&DM,ET@(" @(" @(" @(" @(#L@8W@@/2!S
  15057. XM8V%N6S N+C%=#0IS:&]R=%]L;V]P.@T*(" @(" @("!D96,@(" @(&5B<" @
  15058. XM(" @(" @(" @(" @(" @(" @(#L@+2UC:&%I;E]L96YG=&@-"B @(" @(" @
  15059. XM:GH@(" @("!T:&5?96YD#0H[(&%T('1H:7,@<&]I;G0L(&5D:2 ]/2!S8V%N
  15060. XM*S(L(&5S:2 ]/2!C=7)?;6%T8V@L#0H[(&%X(#T@<V-A;EMB97-T7VQE;BTQ
  15061. XM+BYB97-T7VQE;ET@86YD(&-X(#T@<V-A;ELP+BXQ70T*(" @(" @("!A;F0@
  15062. XM(" @(&5S:2Q74TE:12TQ#0H@(" @(" @(&UO=B @(" @<VDL7W!R979;97-I
  15063. XM*V5S:5T@(" @(" @.R!C=7)?;6%T8V@@/2!P<F5V6V-U<E]M871C:%T-"B @
  15064. XM(" @(" @(" @(" @(" @(" @(" @(" @(" @(" @(" @(" @(" [('1O<"!W
  15065. XM;W)D(&]F(&5S:2!I<R!S=&EL;" P#0H@(" @(" @(&-M<" @(" @97-I+&5D
  15066. XM> D)"3L@8W5R7VUA=&-H(#P](&QI;6ET(#\-"B @(" @(" @:F)E(" @("!S
  15067. XM:&]R="!T:&5?96YD#0ID;U]S8V%N.@T*(" @(" @("!C;7 @(" @(&%X+'=O
  15068. XM<F0@<'1R(%]W:6YD;W=;96)X*V5S:2TQ72 @(#L@8VAE8VL@;6%T8V@@870@
  15069. XM8F5S=%]L96XM,0T*(" @(" @("!J;F4@(" @('-H;W)T7VQO;W -"B @(" @
  15070. XM(" @8VUP(" @("!C>"QW;W)D('!T<B!?=VEN9&]W6V5S:5T@(" @(" @(" [
  15071. XM(&-H96-K(&UI;E]M871C:%]L96YG=&@@;6%T8V@-"B @(" @(" @:FYE(" @
  15072. XM("!S:&]R=%]L;V]P#0H-"B @(" @(" @;&5A(" @("!E<VDL7W=I;F1O=UME
  15073. XM<VDK,ET@(" @(" [('-I(#T@;6%T8V@-"B @(" @(" @;6]V(" @("!E87@L
  15074. XM961I(" @(" @(" @(" @(" @(" [(&%X(#T@<V-A;BLR#0H@(" @(" @(&UO
  15075. XM=B @(" @96-X+"A-05A?34%40T@M,BDO,B @(" @.R!S8V%N(&9O<B!A="!M
  15076. XM;W-T($U!6%]-051#2"!B>71E<PT*(" @(" @("!R97!E(" @(&-M<'-W(" @
  15077. XM(" @(" @(" @(" @(" @(#L@;&]O<"!U;G1I;"!M:7-M871C: T*(" @(" @
  15078. XM("!J92 @(" @(&UA>&UA=&-H(" @(" @(" @(" @(" @(#L@;6%T8V@@;V8@
  15079. XM;&5N9W1H($U!6%]-051#2#\-"FUI<VUA=&-H.@T*(" @(" @("!M;W8@(" @
  15080. XM(&-L+%ME9&DM,ET@(" @(" @(" @(" @(#L@;6ES;6%T8V@@;VX@9FER<W0@
  15081. XM;W(@<V5C;VYD(&)Y=&4_#0H@(" @(" @('-U8B @(" @8VPL6V5S:2TR72 @
  15082. XM(" @(" @(" @(" @.R!C;" ](# @:68@9FER<W0@8GET97,@97%U86P-"B @
  15083. XM(" @(" @>&-H9R @("!E87@L961I(" @(" @(" @(" @(" @(" [(&5D:2 ]
  15084. XM('-C86XK,BP@96%X(#T@96YD(&]F('-C86X-"B @(" @(" @<W5B(" @("!E
  15085. XM87@L961I(" @(" @(" @(" @(" @(" [(&5A>" ](&QE;@T*"7-U8@EE<VDL
  15086. XM96%X(" @(" @(" )"3L@97-I(#T@8W5R7VUA=&-H("L@,B K(&]F9G-E="AW
  15087. XM:6YD;W<I#0H)<W5B"65S:2PR*V]F9G-E="!?=VEN9&]W(" @(#L@97-I(#T@
  15088. XM8W5R7VUA=&-H#0H@(" @(" @('-U8B @(" @8VPL,2 @(" @(" @(" @(" @
  15089. XM(" @(" @.R!S970@8V%R<GD@:68@8VP@/3T@," H8V%N)W0@=7-E($1%0RD-
  15090. XM"B @(" @(" @861C(" @("!E87@L," @(" @(" @(" @(" @(" @(" [(&5A
  15091. XM>" ](&-A<G)Y(#\@;&5N*S$@.B!L96X-"B @(" @(" @8VUP(" @("!E87@L
  15092. XM96)X(" @(" @(" @(" @(" @(" [(&QE;B ^(&)E<W1?;&5N(#\-"B @(" @
  15093. XM(" @:FQE(" @("!L;VYG7VQO;W -"B @(" @(" @;6]V(" @("!?;6%T8VA?
  15094. XM<W1A<G0L97-I(" @(" @(" [(&UA=&-H7W-T87)T(#T@8W5R7VUA=&-H#0H@
  15095. XM(" @(" @(&UO=B @(" @96)X+&5A>" @(" @(" @(" @(" @(" @.R!E8G@@
  15096. XM/2!B97-T7VQE;B ](&QE;@T*(" @(" @("!C;7 @(" @(&5A>"Q-05A?34%4
  15097. XM0T@@(" @(" @(" @(#L@;&5N(#X]($U!6%]-051#2" _#0H@(" @(" @(&IL
  15098. XM(" @(" @;&]N9U]L;V]P#0IT:&5?96YD.@T*(" @(" @("!M;W8@(" @(&5A
  15099. XM>"QE8G@@(" @(" @(" @(" @(" @(#L@<F5S=6QT(#T@96%X(#T@8F5S=%]L
  15100. XM96X-"@EP;W )96)X#0H@(" @(" @('!O<" @(" @97-I#0H@(" @(" @('!O
  15101. XM<" @(" @961I#0H@(" @(" @('!O<" @(" @96)P#0H@(" @(" @(')E= T*
  15102. XM;6%X;6%T8V@Z(" @(" @(" @(" @(" @(" @(" @(" @(" @(" @(#L@8V]M
  15103. XM92!H97)E(&EF(&UA>&EM=6T@;6%T8V@-"B @(" @(" @8VUP<V(@(" @(" @
  15104. XM(" @(" @(" @(" @(" @(" @(" [(&EN8W)E;65N="!E<VD@86YD(&5D:0T*
  15105. XM(" @(" @("!J;7 @(" @(&UI<VUA=&-H(" @(" @(" @(" @(" @(#L@9F]R
  15106. XM8V4@;6%T8VA?;&5N9W1H(#T@34%87TQ%3D=42 T*#0IL;VYG97-T7VUA=&-H
  15107. X=7R!E;F1P#0H-"E]415A4(" @96YD<PT*96YD#0H*
  15108. Xend
  15109. END_OF_FILE
  15110.  if test 8134 -ne `wc -c <'os2/match32.asm.UU'`; then
  15111.     echo shar: \"'os2/match32.asm.UU'\" unpacked with wrong size!
  15112.   else
  15113.     echo shar: Uudecoding \"'os2/match32.asm'\" \(5879 characters\)
  15114.     cat os2/match32.asm.UU | uudecode
  15115.     if test 5879 -ne `wc -c <'os2/match32.asm'`; then
  15116.       echo shar: \"'os2/match32.asm'\" uudecoded with wrong size!
  15117.     else
  15118.       rm os2/match32.asm.UU
  15119.     fi
  15120.   fi
  15121.   # end of 'os2/match32.asm.UU'
  15122. fi
  15123. if test -f 'vms/VMSmunch.h' -a "${1}" != "-c" ; then 
  15124.   echo shar: Will not clobber existing file \"'vms/VMSmunch.h'\"
  15125. else
  15126.   echo shar: Extracting \"'vms/VMSmunch.h'\" \(5511 characters\)
  15127.   sed "s/^X//" >'vms/VMSmunch.h' <<'END_OF_FILE'
  15128. X/*---------------------------------------------------------------------------
  15129. X
  15130. X  VMSmunch.h
  15131. X
  15132. X  A few handy #defines, plus the contents of three header files from Joe
  15133. X  Meadows' FILE program.  Used by VMSmunch and by various routines which
  15134. X  call VMSmunch (e.g., in Zip and UnZip).
  15135. X
  15136. X  ---------------------------------------------------------------------------*/
  15137. X
  15138. X#define GET_TIMES       4
  15139. X#define SET_TIMES       0
  15140. X#define GET_RTYPE       1
  15141. X#define CHANGE_RTYPE    2
  15142. X#define RESTORE_RTYPE   3
  15143. X
  15144. X/*---------------------------------------------------------------------------
  15145. X    fatdef.h
  15146. X  ---------------------------------------------------------------------------*/
  15147. X
  15148. X/* This header file was created by Joe Meadows, and is not copyrighted
  15149. X   in any way. No guarantee is made as to the accuracy of the contents
  15150. X   of this header file. This header file was last modified on Sep. 22th,
  15151. X   1987. (Modified to include this statement) */
  15152. X#define FAT$K_LENGTH 32
  15153. X#define FAT$C_LENGTH 32
  15154. X#define FAT$S_FATDEF 32
  15155. X
  15156. Xstruct fatdef {
  15157. X  union  {
  15158. X    unsigned char fat$b_rtype;
  15159. X    struct  {
  15160. X      unsigned fat$v_rtype : 4;
  15161. X      unsigned fat$v_fileorg : 4;
  15162. X    } fat$r_rtype_bits;
  15163. X  } fat$r_rtype_overlay;
  15164. X# define FAT$S_RTYPE 4
  15165. X# define FAT$V_RTYPE 0
  15166. X#   define FAT$C_UNDEFINED 0
  15167. X#   define FAT$C_FIXED 1
  15168. X#   define FAT$C_VARIABLE 2
  15169. X#   define FAT$C_VFC 3
  15170. X#   define FAT$C_STREAM 4
  15171. X#   define FAT$C_STREAMLF 5
  15172. X#   define FAT$C_STREAMCR 6
  15173. X# define FAT$S_FILEORG 4
  15174. X# define FAT$V_FILEORG 4
  15175. X#   define FAT$C_SEQUENTIAL 0
  15176. X#   define FAT$C_RELATIVE 1
  15177. X#   define FAT$C_INDEXED 2
  15178. X#   define FAT$C_DIRECT 3
  15179. X  union  {
  15180. X    unsigned char fat$b_rattrib;
  15181. X    struct  {
  15182. X      unsigned fat$v_fortrancc : 1;
  15183. X      unsigned fat$v_impliedcc : 1;
  15184. X      unsigned fat$v_printcc : 1;
  15185. X      unsigned fat$v_nospan : 1;
  15186. X    } fat$r_rattrib_bits;
  15187. X  } fat$r_rattrib_overlay;
  15188. X#   define FAT$V_FORTRANCC 0
  15189. X#   define FAT$M_FORTRANCC 1
  15190. X#   define FAT$V_IMPLIEDCC 1
  15191. X#   define FAT$M_IMPLIEDCC 2
  15192. X#   define FAT$V_PRINTCC 2
  15193. X#   define FAT$M_PRINTCC 4
  15194. X#   define FAT$V_NOSPAN 3
  15195. X#   define FAT$M_NOSPAN 8
  15196. X  unsigned short int fat$w_rsize;
  15197. X  union
  15198. X  {
  15199. X    unsigned long int fat$l_hiblk;
  15200. X    struct
  15201. X    {
  15202. X      unsigned short int fat$w_hiblkh;
  15203. X      unsigned short int fat$w_hiblkl;
  15204. X    } fat$r_hiblk_fields;
  15205. X  } fat$r_hiblk_overlay;
  15206. X  union
  15207. X  {
  15208. X    unsigned long int fat$l_efblk;
  15209. X    struct
  15210. X    {
  15211. X      unsigned short int fat$w_efblkh;
  15212. X      unsigned short int fat$w_efblkl;
  15213. X    } fat$r_efblk_fields;
  15214. X  } fat$r_efblk_overlay;
  15215. X  unsigned short int fat$w_ffbyte;
  15216. X  unsigned char fat$b_bktsize;
  15217. X  unsigned char fat$b_vfcsize;
  15218. X  unsigned short int fat$w_maxrec;
  15219. X  unsigned short int fat$w_defext;
  15220. X  unsigned short int fat$w_gbc;
  15221. X  char fat$fill[8];
  15222. X  unsigned short int fat$w_versions;
  15223. X};
  15224. X
  15225. X/*---------------------------------------------------------------------------
  15226. X    fchdef.h
  15227. X  ---------------------------------------------------------------------------*/
  15228. X
  15229. X/* This header file was created by Joe Meadows, and is not copyrighted
  15230. X   in any way. No guarantee is made as to the accuracy of the contents
  15231. X   of this header file. This header file was last modified on Sep. 22th,
  15232. X   1987. (Modified to include this statement) */
  15233. X
  15234. X#define FCH$V_BADACL 0x00B
  15235. X#define FCH$M_BADACL (1 << FCH$V_ACL)
  15236. X#define FCH$V_BADBLOCK 0x00E
  15237. X#define FCH$M_BADBLOCK (1 << FCH$V_BADBLOCK)
  15238. X#define FCH$V_CONTIG 0x007
  15239. X#define FCH$M_CONTIG (1 << FCH$V_CONTIG)
  15240. X#define FCH$V_CONTIGB 0x005
  15241. X#define FCH$M_CONTIGB (1 << FCH$V_CONTIGB)
  15242. X#define FCH$V_DIRECTORY 0x00D
  15243. X#define FCH$M_DIRECTORY (1 << FCH$V_DIRECTORY)
  15244. X#define FCH$V_ERASE 0x011
  15245. X#define FCH$M_ERASE (1 << FCH$V_ERASE)
  15246. X#define FCH$V_LOCKED 0x006
  15247. X#define FCH$M_LOCKED (1 << FCH$V_LOCKED)
  15248. X#define FCH$V_MARKDEL 0x00F
  15249. X#define FCH$M_MARKDEL (1 << FCH$V_MARKDEL)
  15250. X#define FCH$V_NOBACKUP 0x001
  15251. X#define FCH$M_NOBACKUP (1 << FCH$V_NOBACKUP)
  15252. X#define FCH$V_NOCHARGE 0x010
  15253. X#define FCH$M_NOCHARGE (1 << FCH$V_NOCHARGE)
  15254. X#define FCH$V_READCHECK 0x003
  15255. X#define FCH$M_READCHECK (1 << FCH$V_READCHECK)
  15256. X#define FCH$V_SPOOL 0x00C
  15257. X#define FCH$M_SPOOL (1 << FCH$V_SPOOL)
  15258. X#define FCH$V_WRITCHECK 0x004
  15259. X#define FCH$M_WRITCHECK (1 << FCH$V_WRITCHECK)
  15260. X#define FCH$V_WRITEBACK 0x002
  15261. X#define FCH$M_WRITEBACK (1 << FCH$V_WRITEBACK)
  15262. X
  15263. Xstruct fchdef  {
  15264. X  unsigned : 1;
  15265. X  unsigned fch$v_nobackup : 1 ;
  15266. X  unsigned fch$v_writeback : 1;
  15267. X  unsigned fch$v_readcheck : 1;
  15268. X  unsigned fch$v_writcheck : 1;
  15269. X  unsigned fch$v_contigb : 1;
  15270. X  unsigned fch$v_locked : 1;
  15271. X  unsigned fch$v_contig : 1;
  15272. X  unsigned : 3;
  15273. X  unsigned fch$v_badacl : 1;
  15274. X  unsigned fch$v_spool : 1;
  15275. X  unsigned fch$v_directory : 1;
  15276. X  unsigned fch$v_badblock : 1;
  15277. X  unsigned fch$v_markdel : 1;
  15278. X  unsigned fch$v_nocharge : 1;
  15279. X  unsigned fch$v_erase : 1;
  15280. X};
  15281. X
  15282. X/*---------------------------------------------------------------------------
  15283. X    fjndef.h
  15284. X  ---------------------------------------------------------------------------*/
  15285. X
  15286. X/* This header file was created by Joe Meadows, and is not copyrighted
  15287. X   in any way. No guarantee is made as to the accuracy of the contents
  15288. X   of this header file. This header file was last modified on Sep. 22th,
  15289. X   1987. (Modified to include this statement) */
  15290. X
  15291. X#define FJN$M_ONLY_RU 1
  15292. X#define FJN$M_RUJNL 2
  15293. X#define FJN$M_BIJNL 4
  15294. X#define FJN$M_AIJNL 8
  15295. X#define FJN$M_ATJNL 16
  15296. X#define FJN$M_NEVER_RU 32
  15297. X#define FJN$M_JOURNAL_FILE 64
  15298. X#define FJN$S_FJNDEF 1
  15299. Xstruct fjndef  {
  15300. X  unsigned fjn$v_only_ru : 1;
  15301. X  unsigned fjn$v_rujnl : 1;
  15302. X  unsigned fjn$v_bijnl : 1;
  15303. X  unsigned fjn$v_aijnl : 1;
  15304. X  unsigned fjn$v_atjnl : 1;
  15305. X  unsigned fjn$v_never_ru : 1;
  15306. X  unsigned fjn$v_journal_file:1;
  15307. X} ;
  15308. END_OF_FILE
  15309.   if test 5511 -ne `wc -c <'vms/VMSmunch.h'`; then
  15310.     echo shar: \"'vms/VMSmunch.h'\" unpacked with wrong size!
  15311.   fi
  15312.   # end of 'vms/VMSmunch.h'
  15313. fi
  15314. if test -f 'vms/vaxclib.opt' -a "${1}" != "-c" ; then 
  15315.   echo shar: Will not clobber existing file \"'vms/vaxclib.opt'\"
  15316. else
  15317.   echo shar: Extracting \"'vms/vaxclib.opt'\" \(30 characters\)
  15318.   sed "s/^X//" >'vms/vaxclib.opt' <<'END_OF_FILE'
  15319. Xsys$library:vaxcrtl.exe/share
  15320. END_OF_FILE
  15321.   if test 30 -ne `wc -c <'vms/vaxclib.opt'`; then
  15322.     echo shar: \"'vms/vaxclib.opt'\" unpacked with wrong size!
  15323.   fi
  15324.   # end of 'vms/vaxclib.opt'
  15325. fi
  15326. echo shar: End of archive 9 \(of 11\).
  15327. cp /dev/null ark9isdone
  15328. MISSING=""
  15329. for I in 1 2 3 4 5 6 7 8 9 10 11 ; do
  15330.     if test ! -f ark${I}isdone ; then
  15331.     MISSING="${MISSING} ${I}"
  15332.     fi
  15333. done
  15334. if test "${MISSING}" = "" ; then
  15335.     echo You have unpacked all 11 archives.
  15336.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  15337. else
  15338.     echo You still must unpack the following archives:
  15339.     echo "        " ${MISSING}
  15340. fi
  15341. exit 0
  15342. exit 0 # Just in case...
  15343. Newsgroups: comp.sources.misc
  15344. From: zip-bugs@cs.ucla.edu (Info-ZIP group)
  15345. Subject:  v31i102:  zip19 - Info-ZIP portable Zip, version 1.9, Part10/11
  15346. Message-ID: <1992Aug23.065015.29701@sparky.imd.sterling.com>
  15347. X-Md4-Signature: 045ddeab004bbd47d01c4755a5d59a76
  15348. Date: Sun, 23 Aug 1992 06:50:15 GMT
  15349. Approved: kent@sparky.imd.sterling.com
  15350.  
  15351. Submitted-by: zip-bugs@cs.ucla.edu (Info-ZIP group)
  15352. Posting-number: Volume 31, Issue 102
  15353. Archive-name: zip19/part10
  15354. Supersedes: zip: Volume 23, Issue 88-96
  15355. Environment: UNIX, VMS, OS/2, MS-DOS, MACINTOSH, WIN-NT, LINUX, MINIX, XOS, !AMIGA, ATARI, symlink, SGI, DEC, Cray, Convex, Amdahl, Sun, PC
  15356.  
  15357. #! /bin/sh
  15358. # This is a shell archive.  Remove anything before this line, then feed it
  15359. # into a shell via "sh file" or similar.  To overwrite existing files,
  15360. # type "sh file -c".
  15361. # The tool that generated this appeared in the comp.sources.unix newsgroup;
  15362. # send mail to comp-sources-unix@uunet.uu.net if you want that tool.
  15363. # Contents:  Readme Where algorith.doc atari/atari.c atari/tc.cfg.UU
  15364. #   contents globals.c install.doc match.s mktime.c
  15365. #   msdos/doturboc.bat.UU msdos/makefile.bor.UU nt/makefile.nt.UU
  15366. #   os2/os2zip.h.UU ziperr.h
  15367. # Wrapped by kent@sparky on Sun Aug 23 01:00:47 1992
  15368. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  15369. echo If this archive is complete, you will see the following message:
  15370. echo '          "shar: End of archive 10 (of 11)."'
  15371. if test -f 'Readme' -a "${1}" != "-c" ; then 
  15372.   echo shar: Will not clobber existing file \"'Readme'\"
  15373. else
  15374.   echo shar: Extracting \"'Readme'\" \(5257 characters\)
  15375.   sed "s/^X//" >'Readme' <<'END_OF_FILE'
  15376. XCopyright (C) 1990-1992 Mark Adler, Richard B. Wales, Jean-loup Gailly,
  15377. XKai Uwe Rommel and Igor Mandrichenko.
  15378. XPermission is granted to any individual or institution to use, copy, or
  15379. Xredistribute this software so long as all of the original files are included
  15380. Xunmodified, that it is not sold for profit, and that this copyright notice
  15381. Xis retained.
  15382. X
  15383. X
  15384. XZip 1.9 is a compression and file packaging utility.  It is analogous to a
  15385. Xcombination of tar and compress and is compatible with PKZIP 1.93a
  15386. X(Phil Katz ZIP) for MSDOS systems.  There is a companion to zip called
  15387. Xunzip (of course) which you should be able to find the same place you
  15388. Xgot zip. (See the file 'where' for details on ftp sites and mail
  15389. Xservers.)
  15390. X
  15391. XThis version of zip has been ported to a wide array of Unix and other
  15392. Xmainframes, minis, and micros including VMS, OS/2, Minix, MSDOS,
  15393. XWindows NT, Atari, and Macintosh (the latter two have not been tested
  15394. Xrecently).  Although highly compatible with PKware's PKZIP and PKUNZIP
  15395. Xutilities of MSDOS fame, our primary objective has been one of
  15396. Xportability and other-than-MSDOS functionality.  Features not found in
  15397. Xthe PKWare version include creation of zip files in a pipe or on a
  15398. Xdevice, VMS and OS/2 extended file attributes, conversion from Unix to
  15399. XMSDOS text file format; and, of course, the ability to run on most of
  15400. Xyour favorite operating systems. And it's free.
  15401. X
  15402. XIf you got this file from zip19.zip, you can extract the rest only
  15403. Xwith unzip 5.0 or pkzip 1.93a. See the file 'Where' if you do not
  15404. Xhave them already.
  15405. X
  15406. XPlease read the file install.doc for information on how to compile and
  15407. Xinstall zip, zipsplit and zipnote.  Please read the file zip.doc for
  15408. Xinformation on how to use them.  The file "contents" is a complete
  15409. Xlist of the files you should have in this distribution.  Also, if you
  15410. Xare using MSDOS, you should read the note on file formats at the end
  15411. Xof the contents file.
  15412. X
  15413. XThis version supports encryption, but the encryption code is distributed
  15414. Xseparately because of the US export regulations. See the file 'Where'
  15415. Xfor access to the encryption code. Decryption can be made with unzip 5.0
  15416. Xor later, or with zipcloak (which is provided in the encryption supplement).
  15417. X
  15418. XAll bug reports and patches should go to zip-bugs@cs.ucla.edu, and
  15419. Xsuggestions for new features can be sent to info-zip@cs.ucla.edu
  15420. X(although we don't promise to use all suggestions).  Patches should be
  15421. Xsent as context diffs only (diff -c).
  15422. X
  15423. XIf you're considering a port, please check in with zip-bugs FIRST,
  15424. Xsince the code is constantly being updated behind the scenes.  We'll
  15425. Xarrange to give you access to the latest source.  The alternative is the
  15426. Xpossibility that your hard work will be tucked away in a sub-archive
  15427. Xand pretty much ignored. A port to VM/CMS would be welcome.
  15428. X
  15429. XIf you'd like to keep up to date with our zip (and companion unzip utility)
  15430. Xdevelopment, join the ranks of BETA testers, add your own thoughts and
  15431. Xcontributions, etc., send your request to Info-ZIP-Request@cs.ucla.edu and 
  15432. Xyou will be added to the Info-ZIP newsletter mailing list.
  15433. X
  15434. X
  15435. XIMPORTANT NOTES:
  15436. X
  15437. X- pkzip 1.93a is only an alpha version (see historical notes below). If
  15438. X  you wish to create zip files compatible with the official version of
  15439. X  pkzip (1.10), you must use zip 1.0. zip 1.9 cannot create files
  15440. X  with the old compression method (implosion).
  15441. X
  15442. X- zip 1.9 is is compatible with pkzip 1.93a, except when two features
  15443. X  are used: encryption or zip file created in a pipe or on a non
  15444. X  seekable device. pkzip versions of 2.0 will support such files, and
  15445. X  unzip 5.0 already supports them. (Thanks to Phil Katz for accepting
  15446. X  our suggested minor changes to the zip file format.)
  15447. X
  15448. X- the ports to the Macintosh and the Atari ST have been provided in
  15449. X  the hope that they can be useful, but they have been adapted from an
  15450. X  older version of zip (1.0) and are still completely untested. A
  15451. X  makefile is still missing for the Mac. Another Macintosh port is
  15452. X  being made by Johnny Lee <johnnyl@microsoft.com> but it requires
  15453. X  more substantial changes so it will be distributed separately.
  15454. X
  15455. X- Please read the file zip.doc, and in particular its list of known bugs
  15456. X  at the end.
  15457. X
  15458. XHistorical notes:
  15459. X
  15460. XAt the time of release of zip 1.9, the official released version of
  15461. XPKZIP is version 1.10. PKZIP 1.93a is only an alpha version, which was
  15462. Xreleased in October 1991. It was supposed to be replaced soon after
  15463. Xwith an official release of pkzip 2.0.  However, Phil Katz has not yet
  15464. Xannounced a release date at the time of writing (Aug 19th, 1992).
  15465. X
  15466. XBeta versions of zip compatible with pkzip 1.93a have been available
  15467. Xsince February 1992 to the info-zip group (see the file 'history').
  15468. XThe zip authors would have preferred to release zip 2.0 only after
  15469. Xpkzip 2.0(*), to ensure full compatibility in case of archive format
  15470. Xchanges between pkzip 1.93a and 2.0. However we feel that we cannot
  15471. Xdelay any further the release of zip 1.9, since all the major features
  15472. Xthat we wanted to put in are now available and well tested by the
  15473. Xinfo-zip group.
  15474. X
  15475. X(*) The version number for the new pkzip was planned to be 2.00, but may
  15476. X    be increased to a number greater than 2.2 to prevent confusion with
  15477. X    several bogus versions, which may destroy all the data on your hard
  15478. X    disk if you run them.
  15479. END_OF_FILE
  15480.   if test 5257 -ne `wc -c <'Readme'`; then
  15481.     echo shar: \"'Readme'\" unpacked with wrong size!
  15482.   fi
  15483.   # end of 'Readme'
  15484. fi
  15485. if test -f 'Where' -a "${1}" != "-c" ; then 
  15486.   echo shar: Will not clobber existing file \"'Where'\"
  15487. else
  15488.   echo shar: Extracting \"'Where'\" \(4412 characters\)
  15489.   sed "s/^X//" >'Where' <<'END_OF_FILE'
  15490. X__________________________________________________________________________
  15491. X
  15492. X  This is the Info-ZIP file ``Where,'' last updated on 20 August 1992.
  15493. X__________________________________________________________________________
  15494. X
  15495. X
  15496. X  SITE OWNERS:  If you're listed in here but the information is not
  15497. X  correct (or if you're a big site but aren't listed at all), please
  15498. X  let us know!  E-mail to zip-bugs at the address given in Readme
  15499. X  and we'll update this file.
  15500. X
  15501. XBasic source-archive names for Info-ZIP's portable Zip, UnZip, and related
  15502. Xutilities (on some ftp sites, the .zip files may have a .zoo equivalent
  15503. Xin zoo 2.10 format):
  15504. X
  15505. X    zip19.zip    Zip 1.9 (includes zipnote and zipsplit)
  15506. X    zip19.tar.Z    ditto, compress'd tar format
  15507. X
  15508. X    unzip50.zip    UnZip 5.0 (includes zipinfo and funzip)
  15509. X    unzip50.tar.Z    ditto, compress'd tar format
  15510. X
  15511. X    wunz12sr.zip    WizUnZip 1.2 support files for Windows 3.1, UnZip 5.0
  15512. X
  15513. X    zcrypt19.zip    encryption/decryption support (includes zipcloak)
  15514. X
  15515. XRelated archives and files:
  15516. X
  15517. X    UnzpHist.zip    changes history of UnZip, back to 2.0
  15518. X
  15519. X    zip19x.zip      MSDOS executables and docs for zip, zipnote, zipsplit
  15520. X    unzip50.exe     MSDOS executable for unzip
  15521. X
  15522. X    zip19_16.zip    OS/2 1.x 16-bit executables and docs
  15523. X    zip19_32.zip    OS/2 2.x 32-bit executables and docs
  15524. X    unz50_16.exe    OS/2 1.x 16-bit executable
  15525. X    unz50_32.exe    OS/2 2.x 32-bit executable
  15526. X
  15527. X    zip19vms.zip    VMS executables and docs for zip, zipnote, zipsplit
  15528. X    unz50vms.exe    VMS executable for unzip
  15529. X
  15530. X    zip_unzip.hqx   Macinstosh executables (zip 1.0 only, 1.9 not ready)
  15531. X
  15532. X    winunz12.zip    Windows 3.1 executables (zip 1.0 only, 1.9 not ready)
  15533. X
  15534. X    pkz110eu.exe    MS-DOS PKZIP/PKUNZIP 1.1 (self-extracting archive)
  15535. X    pkz193a.exe    MS-DOS PKZIP/PKUNZIP beta 1.93 (self-extracting)
  15536. X    pkz102-2.exe    OS/2 PKZIP/PKUNZIP 1.02 (self-extracting)
  15537. X
  15538. Xftp sites for the US-exportable sources and executables.  Look for
  15539. Xthe file names given above in the following directories.  Some sites
  15540. Xlike to use slightly different names, such as zip-1.9.tar-z instead
  15541. Xof zip19.tar.Z.
  15542. X
  15543. X    wuarchive.wustl.edu:/packages/compression/...
  15544. X    wuarchive.wustl.edu:/mirrors/misc/unix/...
  15545. X    wuarchive.wustl.edu:/mirrors/misc/vaxvms/...
  15546. X    wuarchive.wustl.edu:/mirrors/msdos/zip/...
  15547. X    wuarchive.wustl.edu:/mirrors/msdos/windows3/...
  15548. X
  15549. X    ftp.uu.net:/pub/zip/...
  15550. X
  15551. X    ftp-os2.nmsu.edu:/pub/os2/2.0/archivers/...
  15552. X    ftp-os2.nmsu.edu:/pub/os2/all/archivers/...
  15553. X
  15554. X    Zip 1.9 and UnZip 5.0 will also be available at any comp.sources.misc
  15555. X    archive site as soon as they are posted.
  15556. X
  15557. X    wuarchive.wustl.edu:/mirrors/msdos/zip/pkz110eu.exe
  15558. X    ux1.cso.uiuc.edu:/pc/exec-pc/pkz193a.exe    [128.174.5.59]
  15559. X
  15560. Xftp sites for the encryption and decryption sources:
  15561. X
  15562. X    NOTE:  Non-US users, please do NOT ftp from the US site (US
  15563. X    regulations and all that).  Likewise, US users, please do not
  15564. X    ftp from the European sites (it's not illegal, but it sure is
  15565. X    a waste of expensive bandwidth).
  15566. X
  15567. X    From the US:
  15568. X       wuarchive.wustl.edu:/mirrors3/garbo.uwasa.fi/arcutil/zcrypt19.zip
  15569. X
  15570. X    Outside the US:
  15571. X       garbo.uwasa.fi:/pc/arcutil/zcrypt19.zip
  15572. X       ftp.win.tue.nl:/pub/compression/zip/zcrypt19.zip
  15573. X       ftp.inria.fr:/system/arch-compr/zcrypt19.zip
  15574. X       ftp.informatik.tu-muenchen.de:/pub/utils/archiver/zcrypt19.zip
  15575. X         (mail server at ftp-mailer@ftp.informatik.tu-muenchen.de)
  15576. X
  15577. XTo find other ftp sites:
  15578. X
  15579. X    The "archie" ftp database utility can be used to find an ftp site
  15580. X    near you.  If you don't know how to use it, DON'T ASK US--check the
  15581. X    Usenet groups news.newusers.questions or news.answers or some such,
  15582. X    or ask your system administrator.
  15583. X
  15584. XUUCP sites:
  15585. X
  15586. X    uunet!~/pub/zip/ ...
  15587. X
  15588. XMail servers:
  15589. X
  15590. X    If you don't have anonymous FTP capability, you can mail one
  15591. X    of the following commands (in the body of an e-mail message) to
  15592. X    listserv@vm1.nodak.edu or listserv@vm.ecs.rpi.edu in order to
  15593. X    get a copy via e-mail:
  15594. X
  15595. X    /pdget mail pd:<misc.unix>unzip50.tar-z uuencode
  15596. X    /pdget mail pd:<misc.unix>zip19.zip uuencode
  15597. X   or:    /pdget mail pd:<misc.unix>zip19.tar-z uuencode
  15598. X
  15599. X    To get the encryption source by email, send the following commands
  15600. X    to ftp-mailer@ftp.informatik.tu-muenchen.de:
  15601. X
  15602. X    get /pub/utils/archiver/zcrypt19.zip
  15603. X        quit
  15604. X
  15605. X__________________________________________________________________________
  15606. X
  15607. XAgain, if someone repackages any of the source or executable archives in
  15608. XVMS-, Mac- or Atari-specific formats, please let us know (send e-mail to 
  15609. Xzip-bugs at the address listed in README).
  15610. X__________________________________________________________________________
  15611. X
  15612. END_OF_FILE
  15613.   if test 4412 -ne `wc -c <'Where'`; then
  15614.     echo shar: \"'Where'\" unpacked with wrong size!
  15615.   fi
  15616.   # end of 'Where'
  15617. fi
  15618. if test -f 'algorith.doc' -a "${1}" != "-c" ; then 
  15619.   echo shar: Will not clobber existing file \"'algorith.doc'\"
  15620. else
  15621.   echo shar: Extracting \"'algorith.doc'\" \(2948 characters\)
  15622.   sed "s/^X//" >'algorith.doc' <<'END_OF_FILE'
  15623. XZip's deflation algorithm is a variation of LZ77 (Lempel-Ziv 1977, see
  15624. Xreference below). It finds duplicated strings in the input data.  The
  15625. Xsecond occurrence of a string is replaced by a pointer to the previous
  15626. Xstring, in the form of a pair (distance, length).  Distances are
  15627. Xlimited to 32K bytes, and lengths are limited to 258 bytes. When a
  15628. Xstring does not occur anywhere in the previous 32K bytes, it is
  15629. Xemitted as a sequence of literal bytes.  (In this description,
  15630. X'string' must be taken as an arbitrary sequence of bytes, and is not
  15631. Xrestricted to printable characters.)
  15632. X
  15633. XLiterals or match lengths are compressed with one Huffman tree, and
  15634. Xmatch distances are compressed with another tree. The trees are stored
  15635. Xin a compact form at the start of each block. The blocks can have any
  15636. Xsize (except that the compressed data for one block must fit in
  15637. Xavailable memory). A block is terminated when zip determines that it
  15638. Xwould be useful to start another block with fresh trees. (This is
  15639. Xsomewhat similar to compress.)
  15640. X
  15641. XDuplicated strings are found using a hash table. All input strings of
  15642. Xlength 3 are inserted in the hash table. A hash index is computed for
  15643. Xthe next 3 bytes. If the hash chain for this index is not empty, all
  15644. Xstrings in the chain are compared with the current input string, and
  15645. Xthe longest match is selected.
  15646. X
  15647. XThe hash chains are searched starting with the most recent strings, to
  15648. Xfavor small distances and thus take advantage of the Huffman encoding.
  15649. XThe hash chains are singly linked. There are no deletions from the
  15650. Xhash chains, the algorithm simply discards matches that are too old.
  15651. X
  15652. XTo avoid a worst-case situation, very long hash chains are arbitrarily
  15653. Xtruncated at a certain length, determined by a runtime option (zip -1
  15654. Xto -9). So zip does not always find the longest possible match but
  15655. Xgenerally finds a match which is long enough.
  15656. X
  15657. Xzip also defers the selection of matches with a lazy evaluation
  15658. Xmechanism. After a match of length N has been found, zip searches for a
  15659. Xlonger match at the next input byte. If a longer match is found, the
  15660. Xprevious match is truncated to a length of one (thus producing a single
  15661. Xliteral byte) and the longer match is emitted afterwards.  Otherwise,
  15662. Xthe original match is kept, and the next match search is attempted only
  15663. XN steps later.
  15664. X
  15665. XThe lazy match evaluation is also subject to a runtime parameter. If
  15666. Xthe current match is long enough, zip reduces the search for a longer
  15667. Xmatch, thus speeding up the whole process. If compression ratio is more
  15668. Ximportant than speed, zip attempts a complete second search even if
  15669. Xthe first match is already long enough.
  15670. X
  15671. XJean-loup Gailly
  15672. Xjloup@chorus.fr
  15673. X
  15674. XReferences:
  15675. X
  15676. X[LZ77] Ziv J., Lempel A., "A Universal Algorithm for Sequential Data
  15677. XCompression", IEEE Transactions on Information Theory", Vol. 23, No. 3,
  15678. Xpp. 337-343.
  15679. X
  15680. XAPPNOTE.TXT documentation file in PKZIP 1.93a. It is available by
  15681. Xftp in ux1.cso.uiuc.edu:/pc/exec-pc/pkz193a.exe [128.174.5.59]
  15682. END_OF_FILE
  15683.   if test 2948 -ne `wc -c <'algorith.doc'`; then
  15684.     echo shar: \"'algorith.doc'\" unpacked with wrong size!
  15685.   fi
  15686.   # end of 'algorith.doc'
  15687. fi
  15688. if test -f 'atari/atari.c' -a "${1}" != "-c" ; then 
  15689.   echo shar: Will not clobber existing file \"'atari/atari.c'\"
  15690. else
  15691.   echo shar: Extracting \"'atari/atari.c'\" \(1896 characters\)
  15692.   sed "s/^X//" >'atari/atari.c' <<'END_OF_FILE'
  15693. X/*
  15694. X * ATARI.C
  15695. X *
  15696. X * Necessary interface functions, mostly for conversion
  15697. X * of path names.
  15698. X */
  15699. X#ifdef ATARI_ST
  15700. X
  15701. X#include <stdio.h>
  15702. X#include <stdlib.h>
  15703. X#include <tos.h>
  15704. X#include <ext.h>
  15705. X
  15706. X#define FNMAX 256
  15707. X#define OF(sig) sig
  15708. X
  15709. Xchar *st_fn OF((char *));
  15710. X
  15711. Xchar *st_fn(s)
  15712. Xchar *s;
  15713. X{
  15714. Xstatic char tosname [ FNMAX ];
  15715. Xchar *t = tosname;
  15716. X
  15717. X  while ( *t=*s++ ) {
  15718. X    if ( *t == '/' )
  15719. X      *t = '\\';
  15720. X    t++;
  15721. X  }
  15722. X  
  15723. X  return(tosname);
  15724. X}
  15725. X
  15726. Xint st_unlink(f)
  15727. Xchar *f;
  15728. X{
  15729. X  return(unlink(st_fn(f)));
  15730. X}
  15731. X
  15732. X/* Fake chmod with minimalistic functionality.
  15733. X * [ anyway people will be in trouble with the readonly files
  15734. X *   produces by this, since 'normal' users don't own the
  15735. X *   'tools' to manipulate these. ]
  15736. X */
  15737. Xint st_chmod(f, a)
  15738. Xchar *f;                /* file path */
  15739. Xint a;                  /* attributes returned by getfileattr() */
  15740. X/* Give the file f the attributes a, return non-zero on failure */
  15741. X{
  15742. X  if ( ! ( a & S_IWRITE ) )
  15743. X    if (Fattrib(st_fn(f), 1, FA_READONLY) < 0 )
  15744. X      return(-1);
  15745. X  return 0;
  15746. X}
  15747. X
  15748. X/*
  15749. X * mktemp is not part of the Turbo C library.
  15750. X */ 
  15751. Xchar *st_mktemp(s)
  15752. Xchar *s;
  15753. X{
  15754. Xchar *t;
  15755. Xlong i;
  15756. X  for(t=s; *t; t++)
  15757. X    if ( *t == '/' )
  15758. X      *t = '\\';
  15759. X  t -= 6;
  15760. X  i = (unsigned long)s % 1000000L;
  15761. X  do {
  15762. X    sprintf(t, "%06ld", i++);
  15763. X  } while ( Fsfirst(s, 0x21) == 0 );
  15764. X  return(s);
  15765. X}
  15766. X
  15767. XFILE *st_fopen(f,m)
  15768. Xchar *f;
  15769. Xchar *m;
  15770. X{
  15771. X  return(fopen(st_fn(f),m));
  15772. X}
  15773. X
  15774. Xint st_open(f,m)
  15775. Xchar *f;
  15776. Xint m;
  15777. X{
  15778. X  return(open(st_fn(f),m));
  15779. X}
  15780. X
  15781. Xint st_stat(f, b)
  15782. Xchar *f;
  15783. Xstruct stat *b;
  15784. X{
  15785. X  return(stat(st_fn(f),b));
  15786. X}
  15787. X
  15788. Xint st_findfirst(n,d,a)
  15789. Xchar *n;
  15790. Xstruct ffblk *d;
  15791. Xint a;
  15792. X{
  15793. X  return(findfirst( st_fn(n),(struct ffblk *)d,a));
  15794. X}
  15795. X
  15796. X
  15797. Xint st_rename(s, d)
  15798. Xchar *s, *d;
  15799. X{
  15800. Xchar tosname [ FNMAX ];
  15801. Xchar *t = tosname;
  15802. X
  15803. X  while ( *t=*s++ ) {
  15804. X    if ( *t == '/' )
  15805. X      *t = '\\';
  15806. X    t++;
  15807. X  }
  15808. X  return(rename(tosname, st_fn(d)));
  15809. X}  
  15810. X
  15811. Xint st_rmdir(d)
  15812. Xchar *d;
  15813. X{
  15814. X  return(Ddelete(st_fn(d)));
  15815. X}
  15816. X
  15817. X#endif /* ?ATARI_ST */
  15818. END_OF_FILE
  15819.   if test 1896 -ne `wc -c <'atari/atari.c'`; then
  15820.     echo shar: \"'atari/atari.c'\" unpacked with wrong size!
  15821.   fi
  15822.   # end of 'atari/atari.c'
  15823. fi
  15824. if test -f 'atari/tc.cfg.UU' -a "${1}" != "-c" ; then 
  15825.   echo shar: Will not clobber existing file \"'atari/tc.cfg.UU'\"
  15826. else
  15827.   echo shar: Extracting \"'atari/tc.cfg.UU'\" \(3563 characters\)
  15828.   sed "s/^X//" >'atari/tc.cfg.UU' <<'END_OF_FILE'
  15829. Xbegin 666 atari/tc.cfg
  15830. XM @( "C0                                                     
  15831. XM                                                            
  15832. XM                                                            
  15833. XM                                                            
  15834. XM                                                            
  15835. XM                                                            
  15836. XM                                                            
  15837. XM                                                            
  15838. XM                                                            
  15839. XM                                              0             
  15840. XM            93I<=&-<:6YC;'5D90                              
  15841. XM     $%405))7U-4  !84$]25   3U)4                            
  15842. XM                                                    ,C4  #$P
  15843. XM,  S,@  ,@                                                  
  15844. XM                                                            
  15845. XM                                                            
  15846. XM                                                            
  15847. XM                                                            
  15848. XM                                                            
  15849. XM                                                            
  15850. XM                                                            
  15851. XM                                                            
  15852. XM                                                            
  15853. XM                                                            
  15854. XM                                                            
  15855. XM                                                            
  15856. XM                                                !           
  15857. XM                                           X,3DR        93I<
  15858. XM=&-<;&EB                                                    
  15859. XM                                                            
  15860. XM                                                            
  15861. XM                                                            
  15862. XM1CI<6DE07%I)4%Q:25 N4%)*                                    
  15863. XM                                                            
  15864. XM                                                  !&.EQ:25!<
  15865. XM6DE07 !#+EI)4                                               
  15866. XM                                                            
  15867. XM                                                            
  15868. XM                                                            
  15869. XM                                                            
  15870. XM                                /S\_                        
  15871. XM @ # $8 %$8Z7%I)4%Q:25!<34%+149)3$4 7$U!2T5&24Q%      ,     
  15872. XM       )^?H  #>* P  ")'D    $   -XH#$  (FIH "LUN        # @ 
  15873. XM   0                  GZ(@       0 (  $ "  !     0   !  "=)P
  15874. XM      !#    0P      1@ 41CI<6DE07%I)4%Q:25 N4%)*  !<34%+149)
  15875. XM3$4      P            GY^@  -XH#   (D>0    0   WB@,0  B:F@ *
  15876. XMS6X        ,"    !                  "?HB       !  @  0 (  $ 
  15877. XM   !    $  )TG                   0!& !1%.EQ40UQ$149!54Q4+E!2
  15878. XM2@   %Q-04M%1DE,10     #            "?GZ   WB@,   B1Y    !  
  15879. XM #>* Q  ")J:  K-;@        P(    $                  )^B(     
  15880. XM  $ "  !  @  0    $    0  G2<  !    L@   +(    ! $8 %$UE<W-A
  15881. XM9V5S                                                        
  15882. XM                                                            
  15883. XM                                              (             
  15884. XM                                                            
  15885. XM                                                            
  15886. XL                                                            
  15887. Xend
  15888. END_OF_FILE
  15889.  if test 3563 -ne `wc -c <'atari/tc.cfg.UU'`; then
  15890.     echo shar: \"'atari/tc.cfg.UU'\" unpacked with wrong size!
  15891.   else
  15892.     echo shar: Uudecoding \"'atari/tc.cfg'\" \(2564 characters\)
  15893.     cat atari/tc.cfg.UU | uudecode
  15894.     if test 2564 -ne `wc -c <'atari/tc.cfg'`; then
  15895.       echo shar: \"'atari/tc.cfg'\" uudecoded with wrong size!
  15896.     else
  15897.       rm atari/tc.cfg.UU
  15898.     fi
  15899.   fi
  15900.   # end of 'atari/tc.cfg.UU'
  15901. fi
  15902. if test -f 'contents' -a "${1}" != "-c" ; then 
  15903.   echo shar: Will not clobber existing file \"'contents'\"
  15904. else
  15905.   echo shar: Extracting \"'contents'\" \(4614 characters\)
  15906.   sed "s/^X//" >'contents' <<'END_OF_FILE'
  15907. XCopyright (C) 1990-1992 Mark Adler, Richard B. Wales, Jean-loup Gailly,
  15908. XKai Uwe Rommel and Igor Mandrichenko.
  15909. XPermission is granted to any individual or institution to use, copy, or
  15910. Xredistribute this software so long as all of the original files are included
  15911. Xunmodified, that it is not sold for profit, and that this copyright notice
  15912. Xis retained.
  15913. X
  15914. XThis file is a complete list of files mentioned in the above copyright.  Some
  15915. Xof the files in this list explicitly state in their text that they are public
  15916. Xdomain or not copyrighted.  These files can be distributed separately and are
  15917. Xmarked below with asterisks.
  15918. X
  15919. Xfile            what it is
  15920. X----            ----------
  15921. XReadme          What zip is; general information.
  15922. XWhere           where Zip/UnZip and encryption/decryption support can be found
  15923. Xalgorith.doc    Description of the deflation algorithm
  15924. Xbits.c          Output variable-length bit strings.
  15925. Xcontents        This file.
  15926. Xdeflate.c       Deflation compression method
  15927. Xfileio.c        System dependent routines (most of them anyway).
  15928. Xglobals.c       Global variables.
  15929. Xhistory         List of changes in the versions leading up to this one.
  15930. Xinfozip.who     List of contributors to the portable Zip project.
  15931. Xinstall.doc     Documentation for Zip compilation and installation
  15932. Xmakecrc.c       * Generate the CRC table in util.c and shrink.c.
  15933. Xmakefile        Unix make file.
  15934. Xmatch.s         Optimized 386 version of longest_match() (Unix & OS/2)
  15935. Xmktime.c        Version of mktime for systems without it (currently unused)
  15936. Xrevision.h      Contains the program version number and revision date.
  15937. Xtailor.h        * Tailors the compilation to the system being compiled on.
  15938. Xtrees.c         Encode source values using variable-length binary code trees.
  15939. Xutil.c          Miscellaneous utility routines.
  15940. Xzip.1           Source for the Zip man page (zip.doc).
  15941. Xzip.c           Main routine for Zip.
  15942. Xzip.doc         Documentation for Zip (zip.1 processed).
  15943. Xzip.h           Header for all Zip modules.
  15944. Xziperr.h        Error messages in Zip.
  15945. Xzipfile.c       Zip file format handler.
  15946. Xzipnote.c       Main routine for ZipNote.
  15947. Xzipsplit.c      Main routine for ZipSplit.
  15948. Xzipup.c         Applies deflate or store methods to compress an entry.
  15949. Xatari/atari.c         Atari ST specific routines
  15950. Xatari/makefile.st     Turbo C makefile
  15951. Xatari/stzip.lnk       Linker command file for zip
  15952. Xatari/stzip.prj       Turbo C project file
  15953. Xatari/stzipn.lnk      Linker command file for zipnote
  15954. Xatari/stzips.lnk      Linker command file for zipsplit
  15955. Xatari/tc.cfg          Turbo C configuration file
  15956. Xmac/macfile.c         Macintosh specific routines
  15957. Xmac/macstat.c         Macintosh specific routines
  15958. Xmac/macstat.h         Macintosh specific header file
  15959. Xmsdos/doturboc.bat    Batch file for compiling under Turbo C 2.0.
  15960. Xmsdos/makefile.bor    MSDOS Borland C++ make file.
  15961. Xmsdos/makefile.gcc    MSDOS DJGCC make file.
  15962. Xmsdos/makefile.msc    MSDOS Microsoft C make file.
  15963. Xmsdos/match.asm       Optimized 8086 version of longest_match().
  15964. Xmsdos/tcconfig.tc     TurboC 2.0 configuration file
  15965. Xmsdos/zip.prj         Project file for Borland (Turbo) C++.
  15966. Xmsdos/zipnote.prj     Project file for Borland (Turbo) C++.
  15967. Xmsdos/zipsplit.prj    Project file for Borland (Turbo) C++.
  15968. Xnt/makefile.nt        Makefile for Windows NT
  15969. Xos2/makefile.os2      OS/2 make file.
  15970. Xos2/match32.asm       Optimized 386 version of longest_match() (*untested*)
  15971. Xos2/os2zip.c          * Directory routines for OS/2.
  15972. Xos2/os2zip.h          * Definitions of functions in os2zip.c.
  15973. Xos2/zip.def           OS/2 def file for Zip.
  15974. Xvms/VMSmunch.c        file manipulation, adapted from Joe Meadows' FILE
  15975. Xvms/VMSmunch.h        definitions for VMSmunch.c
  15976. Xvms/descrip.mms       VMS makefile
  15977. Xvms/make_gcc.com      VMS command file for compilation with gcc.
  15978. Xvms/make_vaxc.com     VMS command file for compilation with Vax C.
  15979. Xvms/makefile.vms      VMS makefile for use with Todd Aven's MAKE/VMS
  15980. Xvms/vaxclib.opt       VMS option file
  15981. Xvms/vms.c             VMS specific code
  15982. Xvms/vms_zip.rnh       VMS manual page
  15983. X
  15984. XAll of the files are in Unix (LF only) format except for the msdos and os2
  15985. Xfiles.  On MSDOS and OS/2 systems, you can use the -a option of unzip to
  15986. Xconvert the source files to CRLF format.  This is only necessary if you wish
  15987. Xto edit the files -- they will compile as is with Microsoft C and
  15988. XTurbo/Borland C++ 1.0 or later.  However, you will have to convert the files
  15989. X(using unzip -a) to the CRLF format to compile with the older Turbo C 1.0 or
  15990. X2.0. In this case, do not convert the binary file turboc.cfg.
  15991. XYou should be able to find unzip the same place you found this (see the
  15992. Xfile 'where').
  15993. END_OF_FILE
  15994.   if test 4614 -ne `wc -c <'contents'`; then
  15995.     echo shar: \"'contents'\" unpacked with wrong size!
  15996.   fi
  15997.   # end of 'contents'
  15998. fi
  15999. if test -f 'globals.c' -a "${1}" != "-c" ; then 
  16000.   echo shar: Will not clobber existing file \"'globals.c'\"
  16001. else
  16002.   echo shar: Extracting \"'globals.c'\" \(2576 characters\)
  16003.   sed "s/^X//" >'globals.c' <<'END_OF_FILE'
  16004. X/*
  16005. X
  16006. X Copyright (C) 1990-1992 Mark Adler, Richard B. Wales, Jean-loup Gailly,
  16007. X Kai Uwe Rommel and Igor Mandrichenko.
  16008. X Permission is granted to any individual or institution to use, copy, or
  16009. X redistribute this software so long as all of the original files are included
  16010. X unmodified, that it is not sold for profit, and that this copyright notice
  16011. X is retained.
  16012. X
  16013. X*/
  16014. X
  16015. X/*
  16016. X *  globals.c by Mark Adler.
  16017. X */
  16018. X
  16019. X#define GLOBALS         /* include definition of errors[] in zip.h */
  16020. X#include "zip.h"
  16021. X
  16022. X
  16023. X/* Handy place to build error messages */
  16024. Xchar errbuf[FNMAX+81];
  16025. X
  16026. X/* Argument processing globals */
  16027. Xint recurse = 0;        /* 1=recurse into directories encountered */
  16028. Xint pathput = 1;        /* 1=store path with name */
  16029. Xint method = BEST;      /* one of BEST, DEFLATE (only), or STORE (only) */
  16030. Xint dosify = 0;         /* 1=make new entries look like MSDOS */
  16031. Xint verbose = 0;        /* 1=report oddities in zip file structure */
  16032. Xint level = 5;          /* 0=fastest compression, 9=best compression */
  16033. Xint translate_eol = 0;  /* Translate end-of-line LF -> CR LF */
  16034. X#ifdef VMS
  16035. X   int vmsver = 0;      /* 1=append VMS version number to file names */
  16036. X   int vms_native = 0;  /* 1=store in VMS format */
  16037. X#endif /* VMS */
  16038. X#ifdef OS2
  16039. X   int use_longname_ea = 0; /* 1=use the .LONGNAME EA as the file's name */
  16040. X#endif /* OS2 */
  16041. Xint linkput = 0;        /* 1=store symbolic links as such */
  16042. Xint noisy = 1;          /* 0=quiet operation */
  16043. Xchar *special = ".Z:.zip:.zoo:.arc:.lzh:.arj"; /* List of special suffixes */
  16044. Xchar *key = NULL;       /* Scramble password if scrambling */
  16045. Xchar *tempath = NULL;   /* Path for temporary files */
  16046. XFILE *mesg;             /* stdout by default, stderr for piping */
  16047. X
  16048. X/* Zip file globals */
  16049. Xchar *zipfile;          /* New or existing zip archive (zip file) */
  16050. Xulg zipbeg;             /* Starting offset of zip structures */
  16051. Xulg cenbeg;             /* Starting offset of central directory */
  16052. Xstruct zlist far *zfiles = NULL;  /* Pointer to list of files in zip file */
  16053. Xextent zcount;          /* Number of files in zip file */
  16054. Xextent zcomlen;         /* Length of zip file comment */
  16055. Xchar *zcomment;         /* Zip file comment (not zero-terminated) */
  16056. Xstruct zlist far **zsort;       /* List of files sorted by name */
  16057. Xulg tempzn;             /* Count of bytes written to output zip file */
  16058. X
  16059. X/* Files to operate on that are not in zip file */
  16060. Xstruct flist far *found = NULL; /* List of names found */
  16061. Xstruct flist far * far *fnxt = &found;
  16062. X                        /* Where to put next name in found list */
  16063. Xextent fcount;          /* Count of files in list */
  16064. END_OF_FILE
  16065.   if test 2576 -ne `wc -c <'globals.c'`; then
  16066.     echo shar: \"'globals.c'\" unpacked with wrong size!
  16067.   fi
  16068.   # end of 'globals.c'
  16069. fi
  16070. if test -f 'install.doc' -a "${1}" != "-c" ; then 
  16071.   echo shar: Will not clobber existing file \"'install.doc'\"
  16072. else
  16073.   echo shar: Extracting \"'install.doc'\" \(4088 characters\)
  16074.   sed "s/^X//" >'install.doc' <<'END_OF_FILE'
  16075. XHOW TO INSTALL ZIP
  16076. X     Zip is distributed as C source code that can be compiled on
  16077. X     a wide range of Unix machines, VAXes running VMS, and MSDOS
  16078. X     machines using Microsoft or Borland C++, and OS/2 machines
  16079. X     using Microsoft C.  You will need Unzip 5.0 (under Unix, MSDOS,
  16080. X     or VMS) or PKUNZIP 1.93a (under MSDOS) to unpack the distribution
  16081. X     file, zip19.zip. But since you read this, you have unpacked it
  16082. X     already, or you cheated and got a tar.Z file...
  16083. X
  16084. X     Let's assume however that you start from scratch and have not yet
  16085. X     unpacked the sources. First, unpack the source as follows,
  16086. X     assuming that you have zip19.zip in the current directory.
  16087. X
  16088. X          mkdir zipsrc
  16089. X          cd zipsrc
  16090. X          unzip ../zip19
  16091. X
  16092. X     This extracts all source files and documentation in the
  16093. X     directory called "zipsrc". If you wish to build a version
  16094. X     of zip with encryption capabilities, you must also get the
  16095. X     separate package zcrypt19.zip and uncomment the definition
  16096. X     of MAKE at the beginning of the makefile.
  16097. X
  16098. X     You then do:
  16099. X
  16100. X          make system
  16101. X
  16102. X     where "system" is one of: bsd, bsdold, sysv, sysv_386, sysv_old, sun,
  16103. X     sun_gcc, next, next10, hpux, dnix, cray, 3b1, zilog, aux, convex, aix,
  16104. X     minix, isc, dynix, ultrix, dec_osf1 or xos. If you are using a NeXT
  16105. X     running version 2.0 or greater, then make next.  If you are using 1.0,
  16106. X     then make next10.  If you are using Sun OS 4.x, then make sun (or
  16107. X     sun_gcc if you use gcc). If you are using SVR4 on a 386, use
  16108. X     sysv_386 to get the optimized asm code.
  16109. X
  16110. X     The other special systems are HPUX, DNIX 5.2 or 5.3, Cray Unicos,
  16111. X     AT&T 3B1 (also known as Unix PC or PC 7300), Zilog Zeus, A/UX,
  16112. X     Convex, AIX, MINIX, ISC System V/386, Dynix, Ultrix and DEC OSF/1.
  16113. X
  16114. X     Otherwise, if you are using BSD Unix, try bsd.  If the linker
  16115. X     cannot find _memset or _memcpy, try bsdold.  If you are using
  16116. X     System V Unix or SCO Unix, try sysv or sysv_old.  Also use sysv
  16117. X     on a Silicon Graphics (SGI) machine.  You can also cross-compile
  16118. X     Zip for MSDOS under SCO 386 Unix using "make scodos".
  16119. X
  16120. X     If none of these compiles, links, and functions properly on
  16121. X     your Unix system, see the section BUGS below for how to get
  16122. X     help.
  16123. X
  16124. X     If the appropriate system was selected, then the executables
  16125. X     zip, zipnote and zipsplit will be created.  You can copy them
  16126. X     to an appropriate directory in the search path using:
  16127. X
  16128. X          make install
  16129. X
  16130. X     The defaults are /usr/local/bin for the executables and
  16131. X     /usr/man/man1 for the manual page. Change the macros BINDIR
  16132. X     and MANDIR in makefile if appropriate.
  16133. X
  16134. X     You can use the command "set" to see the current search
  16135. X     path.  If you are using the C-Shell (csh), enter the com-
  16136. X     mand:
  16137. X
  16138. X          rehash
  16139. X
  16140. X     so csh can find the new command in the path.  You are now
  16141. X     ready to use Zip.
  16142. X
  16143. X     You can get rid of the now unnecessary source and object
  16144. X     files with:
  16145. X
  16146. X          cd ..
  16147. X          rm -r zipsrc
  16148. X
  16149. X     This will remove the directory zip and its contents created
  16150. X     by unzip.  You should keep the zip19.zip file around though,
  16151. X     in case you need to build it again or want to give it to a
  16152. X     colleague.
  16153. X
  16154. X     The steps for installation under MSDOS, OS/2, and VMS are
  16155. X     similar to the above: first unzip the distribution files
  16156. X     into their own directory. The system dependant files are
  16157. X     stored in special subdirectories. You may have to
  16158. X     copy or move them to the main sources directory.
  16159. X     Then under MSDOS do one of:
  16160. X
  16161. X          make makefile.msc
  16162. X          make -fmakefile.bor
  16163. X
  16164. X     for Microsoft or Borland C++, respectively. For Turbo C 2.0,
  16165. X     use the configuration file tcconfig.tc, the batch file
  16166. X     doturboc.bat and the project files zip.prj, zipnote.prj
  16167. X     and zipsplit.prj. Make sure to use the compact model.
  16168. X
  16169. X     Under OS/2:
  16170. X
  16171. X          nmake -f makefile.os2
  16172. X
  16173. X     for Microsoft C 6.00.  Under VAX VMS:
  16174. X
  16175. X          @make_vaxc
  16176. X     or:  @make_gcc
  16177. X
  16178. X     For command help on any of the zip* utilities, simply enter
  16179. X     the name with no arguments.
  16180. END_OF_FILE
  16181.   if test 4088 -ne `wc -c <'install.doc'`; then
  16182.     echo shar: \"'install.doc'\" unpacked with wrong size!
  16183.   fi
  16184.   # end of 'install.doc'
  16185. fi
  16186. if test -f 'match.s' -a "${1}" != "-c" ; then 
  16187.   echo shar: Will not clobber existing file \"'match.s'\"
  16188. else
  16189.   echo shar: Extracting \"'match.s'\" \(5410 characters\)
  16190.   sed "s/^X//" >'match.s' <<'END_OF_FILE'
  16191. X/
  16192. X/ Copyright (C) 1990-1992 Mark Adler, Richard B. Wales, Jean-loup Gailly,
  16193. X/ Kai Uwe Rommel and Igor Mandrichenko.
  16194. X/ Permission is granted to any individual or institution to use, copy, or
  16195. X/ redistribute this software so long as all of the original files are included
  16196. X/ unmodified, that it is not sold for profit, and that this copyright notice
  16197. X/ is retained.
  16198. X/
  16199. X/ match.s by Jean-loup Gailly. Translated to 32 bit code by Kai Uwe Rommel.
  16200. X
  16201. X/ match.s, optimized version of longest_match() in deflate.c
  16202. X/ This version is for 386 Unix or OS/2 in 32 bit mode.
  16203. X/ Warning: it uses the AT&T syntax: mov source,dest
  16204. X/ This file is only optional. If you want to force the C version,
  16205. X/ add -DNO_ASM to CFLAGS in makefile and remove match.o from OBJI).
  16206. X/ If you have reduced WSIZE in zip.h, then change its value below.
  16207. X/ This version assumes static allocation of the arrays (-DDYN_ALLOC not used).
  16208. X
  16209. X    .file   "match.s"
  16210. X
  16211. X#if defined(__GO32__) && defined(unix)
  16212. X#  undef unix
  16213. X#endif
  16214. X
  16215. X#ifdef unix
  16216. X#  define _prev             prev
  16217. X#  define _window           window
  16218. X#  define _match_start        match_start
  16219. X#  define _prev_length        prev_length
  16220. X#  define _good_match        good_match
  16221. X#  define _strstart        strstart
  16222. X#  define _max_chain_length max_chain_length
  16223. X
  16224. X#  define _match_init       match_init
  16225. X#  define _longest_match    longest_match
  16226. X#endif
  16227. X
  16228. X#define MAX_MATCH     258
  16229. X#define MAX_MATCH2      128     /* MAX_MATCH/2-1 */
  16230. X#define MIN_MATCH    3
  16231. X#define WSIZE         32768
  16232. X#define MAX_DIST     WSIZE - MAX_MATCH - MIN_MATCH - 1
  16233. X
  16234. X    .globl    _match_init
  16235. X    .globl  _longest_match
  16236. X
  16237. X    .text
  16238. X
  16239. X_match_init:
  16240. X    ret
  16241. X
  16242. X/ -----------------------------------------------------------------------
  16243. X/ Set match_start to the longest match starting at the given string and
  16244. X/ return its length. Matches shorter or equal to prev_length are discarded,
  16245. X/ in which case the result is equal to prev_length and match_start is
  16246. X/ garbage.
  16247. X/ IN assertions: cur_match is the head of the hash chain for the current
  16248. X/   string (strstart) and its distance is <= MAX_DIST, and prev_length >= 1
  16249. X
  16250. X_longest_match:    /* int longest_match(cur_match) */
  16251. X
  16252. X#define cur_match   20(%esp)
  16253. X        / return address                / esp+16
  16254. X        push    %ebp                    / esp+12
  16255. X        push    %edi                    / esp+8
  16256. X    push    %esi                    / esp+4
  16257. X    push    %ebx            / esp
  16258. X
  16259. X/       match        equ esi
  16260. X/       scan         equ edi
  16261. X/       chain_length equ ebp
  16262. X/       best_len     equ ebx
  16263. X/       limit        equ edx
  16264. X
  16265. X    mov     cur_match,%esi
  16266. X        mov     _max_chain_length,%ebp  / chain_length = max_chain_length
  16267. X    mov     _strstart,%edi
  16268. X    mov     %edi,%edx
  16269. X    sub    $ MAX_DIST,%edx         / limit = strstart-MAX_DIST
  16270. X    jae    limit_ok
  16271. X    sub    %edx,%edx               / limit = NIL
  16272. Xlimit_ok:
  16273. X        add    $_window+2,%edi         / edi = offset(window + strstart + 2)
  16274. X        mov    _prev_length,%ebx       / best_len = prev_length
  16275. X        movw     -3(%ebx,%edi),%ax       / ax = scan[best_len-1..best_len]
  16276. X        movw     -2(%edi),%cx            / cx = scan[0..1]
  16277. X    cmp    _good_match,%ebx        / do we have a good match already?
  16278. X        jb      do_scan
  16279. X    shr     $2,%ebp                 / chain_length >>= 2
  16280. X        jmp     do_scan
  16281. X
  16282. X        .align  4
  16283. Xlong_loop:
  16284. X/ at this point, edi == scan+2, esi == cur_match
  16285. X        movw    -3(%ebx,%edi),%ax       / ax = scan[best_len-1..best_len]
  16286. X        movw     -2(%edi),%cx            / cx = scan[0..1]
  16287. Xshort_loop:
  16288. X        dec     %ebp                    / --chain_length
  16289. X        jz      the_end
  16290. X/ at this point, di == scan+2, si == cur_match,
  16291. X/ ax = scan[best_len-1..best_len] and cx = scan[0..1]
  16292. X        and     $ WSIZE-1, %esi
  16293. X        movw     _prev(%esi,%esi),%si    / cur_match = prev[cur_match]
  16294. X                                        / top word of esi is still 0
  16295. X        cmp     %edx,%esi        / cur_match <= limit ?
  16296. X        jbe     the_end
  16297. Xdo_scan:
  16298. X        cmpw    _window-1(%ebx,%esi),%ax /check match at best_len-1
  16299. X        jne     short_loop
  16300. X        cmpw    _window(%esi),%cx       / check min_match_length match
  16301. X        jne     short_loop
  16302. X
  16303. X        lea     _window+2(%esi),%esi    / si = match
  16304. X        mov     %edi,%eax               / ax = scan+2
  16305. X        mov     $ MAX_MATCH2,%ecx       / scan for at most MAX_MATCH bytes
  16306. X#ifdef unix
  16307. X        repz;   cmpsw                   / loop until mismatch
  16308. X#else
  16309. X        repe;   cmpsw
  16310. X#endif
  16311. X        je      maxmatch                / match of length MAX_MATCH?
  16312. Xmismatch:
  16313. X        movb    -2(%edi),%cl            / mismatch on first or second byte?
  16314. X        subb    -2(%esi),%cl            / cl = 0 if first bytes equal
  16315. X        xchg    %edi,%eax               / edi = scan+2, eax = end of scan
  16316. X        sub     %edi,%eax               / eax = len
  16317. X    sub    %eax,%esi               / esi = cur_match + 2 + offset(window)
  16318. X    sub    $_window+2,%esi         / esi = cur_match
  16319. X        subb    $1,%cl                  / set carry if cl == 0 (cannot use DEC)
  16320. X        adc     $0,%eax                 / eax = carry ? len+1 : len
  16321. X        cmp     %ebx,%eax               / len > best_len ?
  16322. X        jle     long_loop
  16323. X        mov     %esi,_match_start       / match_start = cur_match
  16324. X        mov     %eax,%ebx               / ebx = best_len = len
  16325. X        cmp     $ MAX_MATCH,%eax        / len >= MAX_MATCH ?
  16326. X        jl      long_loop
  16327. Xthe_end:
  16328. X        mov     %ebx,%eax               / result = eax = best_len
  16329. X    pop     %ebx
  16330. X        pop     %esi
  16331. X        pop     %edi
  16332. X        pop     %ebp
  16333. X        ret
  16334. Xmaxmatch:
  16335. X        cmpsb
  16336. X        jmp     mismatch
  16337. END_OF_FILE
  16338.   if test 5410 -ne `wc -c <'match.s'`; then
  16339.     echo shar: \"'match.s'\" unpacked with wrong size!
  16340.   fi
  16341.   # end of 'match.s'
  16342. fi
  16343. if test -f 'mktime.c' -a "${1}" != "-c" ; then 
  16344.   echo shar: Will not clobber existing file \"'mktime.c'\"
  16345. else
  16346.   echo shar: Extracting \"'mktime.c'\" \(3614 characters\)
  16347.   sed "s/^X//" >'mktime.c' <<'END_OF_FILE'
  16348. X/* free mktime function
  16349. X   Copyright 1988, 1989 by David MacKenzie <djm@ai.mit.edu>
  16350. X   and Michael Haertel <mike@ai.mit.edu>
  16351. X   Unlimited distribution permitted provided this copyright notice is
  16352. X   retained and any functional modifications are prominently identified.  */
  16353. X
  16354. X/* Note: This version of mktime is ignorant of the tzfile; it does not
  16355. X   return correct results during the few hours around when daylight savings
  16356. X   time goes in to or out of effect.  It also does not allow or adjust
  16357. X   for invalid values in any of the fields, contrary to the ANSI C
  16358. X   specification. */
  16359. X
  16360. X#ifdef MKTIME_MISSING
  16361. X#include <sys/types.h>
  16362. X#include <time.h>
  16363. X
  16364. Xtime_t mkgmtime ();
  16365. X
  16366. X/* Return the equivalent in seconds past 12:00:00 a.m. Jan 1, 1970 GMT
  16367. X   of the local time and date in the exploded time structure `tm',
  16368. X   and set `tm->tm_yday', `tm->tm_wday', and `tm->tm_isdst'.
  16369. X   Return -1 if any of the other fields in `tm' has an invalid value. */
  16370. X
  16371. Xtime_t
  16372. Xmktime (tm)
  16373. X     struct tm *tm;
  16374. X{
  16375. X  struct tm save_tm;            /* Copy of contents of `*tm'. */
  16376. X  struct tm *ltm;               /* Local time. */
  16377. X  time_t then;                  /* The time to return. */
  16378. X
  16379. X  then = mkgmtime (tm);
  16380. X  if (then == -1)
  16381. X    return -1;
  16382. X
  16383. X  /* In case `tm' points to the static area used by localtime,
  16384. X     save its contents and restore them later. */
  16385. X  save_tm = *tm;
  16386. X  /* Correct for the timezone and any daylight savings time.
  16387. X     If a change to or from daylight savings time occurs between when
  16388. X     it is the time in `tm' locally and when it is that time in Greenwich,
  16389. X     the change to or from dst is ignored, but that is a rare case. */
  16390. X  then += then - mkgmtime (localtime (&then));
  16391. X
  16392. X  ltm = localtime (&then);
  16393. X  save_tm.tm_yday = ltm->tm_yday;
  16394. X  save_tm.tm_wday = ltm->tm_wday;
  16395. X  save_tm.tm_isdst = ltm->tm_isdst;
  16396. X  *tm = save_tm;
  16397. X
  16398. X  return then;
  16399. X}
  16400. X
  16401. X/* Nonzero if `y' is a leap year, else zero. */
  16402. X#define leap(y) (((y) % 4 == 0 && (y) % 100 != 0) || (y) % 400 == 0)
  16403. X
  16404. X/* Number of leap years from 1970 to `y' (not including `y' itself). */
  16405. X#define nleap(y) (((y) - 1969) / 4 - ((y) - 1901) / 100 + ((y) - 1601) / 400)
  16406. X
  16407. X/* Number of days in each month of the year. */
  16408. Xstatic char monlens[] =
  16409. X{
  16410. X  31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
  16411. X};
  16412. X
  16413. X/* Return the equivalent in seconds past 12:00:00 a.m. Jan 1, 1970 GMT
  16414. X   of the Greenwich Mean time and date in the exploded time structure `tm',
  16415. X   and set `tm->tm_yday', `tm->tm_wday', and `tm->tm_isdst'.
  16416. X   Return -1 if any of the other fields in `tm' has an invalid value. */
  16417. X
  16418. Xtime_t
  16419. Xmkgmtime (tm)
  16420. X     struct tm *tm;
  16421. X{
  16422. X  int years, months, days, hours, minutes, seconds;
  16423. X
  16424. X  years = tm->tm_year + 1900;   /* year - 1900 -> year */
  16425. X  months = tm->tm_mon;          /* 0..11 */
  16426. X  days = tm->tm_mday - 1;       /* 1..31 -> 0..30 */
  16427. X  hours = tm->tm_hour;          /* 0..23 */
  16428. X  minutes = tm->tm_min;         /* 0..59 */
  16429. X  seconds = tm->tm_sec;         /* 0..61 in ANSI C. */
  16430. X
  16431. X  if (years < 1970
  16432. X      || months < 0 || months > 11
  16433. X      || days < 0
  16434. X      || days > monlens[months] + (months == 1 && leap (years)) - 1
  16435. X      || hours < 0 || hours > 23
  16436. X      || minutes < 0 || minutes > 59
  16437. X      || seconds < 0 || seconds > 61)
  16438. X  return -1;
  16439. X
  16440. X  /* Set `days' to the number of days into the year. */
  16441. X  if (months > 1 && leap (years))
  16442. X    ++days;
  16443. X  while (months-- > 0)
  16444. X    days += monlens[months];
  16445. X  tm->tm_yday = days;
  16446. X
  16447. X  /* Now set `days' to the number of days since Jan 1, 1970. */
  16448. X  days += 365 * (years - 1970) + nleap (years);
  16449. X  tm->tm_wday = (days + 4) % 7; /* Jan 1, 1970 was Thursday. */
  16450. X  tm->tm_isdst = 0;
  16451. X
  16452. X  return 86400 * days + 3600 * hours + 60 * minutes + seconds;
  16453. X}
  16454. X#endif
  16455. END_OF_FILE
  16456.   if test 3614 -ne `wc -c <'mktime.c'`; then
  16457.     echo shar: \"'mktime.c'\" unpacked with wrong size!
  16458.   fi
  16459.   # end of 'mktime.c'
  16460. fi
  16461. if test -f 'msdos/doturboc.bat.UU' -a "${1}" != "-c" ; then 
  16462.   echo shar: Will not clobber existing file \"'msdos/doturboc.bat.UU'\"
  16463. else
  16464.   echo shar: Extracting \"'msdos/doturboc.bat.UU'\" \(669 characters\)
  16465.   sed "s/^X//" >'msdos/doturboc.bat.UU' <<'END_OF_FILE'
  16466. Xbegin 666 msdos/doturboc.bat
  16467. XM.B!4:&ES(&9I;&4@:7,@82!C;VUP;&5M96YT('1O('II<"YP<FH@9F]R(%1U
  16468. XM<F)O($,@,BXP('5S97)S+@T*.B!#:&%N9V4@=&AE(&-O;7!I;&%T:6]N(&9L
  16469. XM86=S(&EF('EO=2!W:7-H("AA9&0@4TU!3$Q?345-(&]R($U%1$E535]-14T-
  16470. XM"CH@=&\@<F5D=6-E('1H92!M96UO<GD@<F5Q=6ER96UE;G1S*2P@86YD('!R
  16471. XM97-S($8Y+BXN#0HZ(%=!4DY)3D<Z('EO=2!M=7-T('5S92!T:&4@8V]M<&%C
  16472. XM="!O<B!L87)G92!M;V1E;"!I;B!T:&ES('9E<G-I;VXN#0H-"G1A<VT@+6UL
  16473. XM("U$1%E.7T%,3$]#("U$4U-?3D517T13(&UA=&-H.PT*#0HZ(%1O(&-O;7!I
  16474. XM;&4@>FEP<W!L:70@86YD('II<&YO=&4L(&1E;&5T92!A;&P@+F]B:B!F:6QE
  16475. XM<RP@861D('1H92!C;VUP:6QA=&EO;@T*.B!F;&%G(%5424PL(&%N9"!U<V4@
  16476. XM>FEP<W!L:70N<')J(&]R('II<&YO=&4N<')J('1O(')E8V]M<&EL92!E=F5R
  16477. X)>71H:6YG+@T*
  16478. Xend
  16479. END_OF_FILE
  16480.   if test 669 -ne `wc -c <'msdos/doturboc.bat.UU'`; then
  16481.     echo shar: \"'msdos/doturboc.bat.UU'\" unpacked with wrong size!
  16482.   else
  16483.     echo shar: Uudecoding \"'msdos/doturboc.bat'\" \(459 characters\)
  16484.     cat msdos/doturboc.bat.UU | uudecode
  16485.     if test 459 -ne `wc -c <'msdos/doturboc.bat'`; then
  16486.       echo shar: \"'msdos/doturboc.bat'\" uudecoded with wrong size!
  16487.     else
  16488.       rm msdos/doturboc.bat.UU
  16489.     fi
  16490.   fi
  16491.   # end of 'msdos/doturboc.bat.UU'
  16492. fi
  16493. if test -f 'msdos/makefile.bor.UU' -a "${1}" != "-c" ; then 
  16494.   echo shar: Will not clobber existing file \"'msdos/makefile.bor.UU'\"
  16495. else
  16496.   echo shar: Extracting \"'msdos/makefile.bor.UU'\" \(5393 characters\)
  16497.   sed "s/^X//" >'msdos/makefile.bor.UU' <<'END_OF_FILE'
  16498. Xbegin 666 msdos/makefile.bor
  16499. XM(R!-86ME9FEL92!F;W(@6FEP+"!::7!#;&]A:RP@6FEP3F]T92!A;F0@6FEP
  16500. XM4W!L:70@9F]R#0HC($)O<FQA;F0@*%1U<F)O*2!#*RL@,2XP(&]R(#(N,"X-
  16501. XM"B,@5V%R;FEN9SH@=&AI<R!F:6QE(&ES(&YO="!S=6ET86)L92!F;W(@5'5R
  16502. XM8F\@0R R+C N(%5S92!Z:7 N<')J(&EN<W1E860N#0H-"B,@5&\@=7-E+"!D
  16503. XM;R B;6%K92 M9FUA:V5F:6QE+F)O<B(-"@T*(R!705).24Y'.B!T:&4@<VUA
  16504. XM;&P@;6]D96P@:7,@;F]T('-U<'!O<G1E9"X@66]U(&UU<W0@=7-E('1H92!C
  16505. XM;VUP86-T(&UO9&5L+@T*(R!!9&0@+41334%,3%]-14T@;W(@+41-141)54U?
  16506. XM345-('1O($-&3$%'4R!I9B!Y;W4@=VES:"!T;R!R961U8V4@=&AE(&UE;6]R
  16507. XM>0T*(R!R97%U:7)E;65N=',N($%D9" M1$Y/7T%332!T;R!#1DQ!1U,@86YD
  16508. XM(')E;6]V92!M871C:"YO8FH@9G)O;2!/0DI)(&EF#0HC('EO=2!D;R!N;W0@
  16509. XM:&%V92!T87-M+@T*#0I#4EE05$\]#0I#3$]!2ST-"D-21DQ!1ST-"@T*(R @
  16510. XM*BHJ($9O<B!E;F-R>7!T:6]N('9E<G-I;VXL(')E;6]V92!T:&4@(R!A="!T
  16511. XM:&4@9G)O;G0@;V8@;F5X=" S(&QI;F5S("HJ*@T*(T-265!43SUC<GEP="YO
  16512. XM8FH-"B-#3$]!2SUZ:7!C;&]A:RYE>&4-"B-#4D9,04<]+41#4EE05 T*#0HC
  16513. XM("TM+2TM+2TM+2TM+2T@5'5R8F\@0RLK+"!";W)L86YD($,K*R M+2TM+2TM
  16514. XM+2TM+2TM#0I-3T1%3#TM;6,-"B-#1DQ!1U,]+7<@+7<M969F("UW+61E9B M
  16515. XM=RUS:6<@+7<M8VQN("UA("UD("U'("U/("U:("0H34]$14PI("0H0U)&3$%'
  16516. XM*0T*0T9,04=3/2U/,B M=R M=RUC;&X@)"A-3T1%3"D@)"A#4D9,04<I#0I5
  16517. XM5$E,1DQ!1U,]+4155$E,("0H0T9,04=3*2 M;PT*0T,]8F-C#0I,1#UB8V,-
  16518. XM"B,@("!R97!L86-E(&)C8R!W:71H('1C8R!F;W(@5'5R8F\@0RLK(#$N, T*
  16519. XM3$1&3$%'4STD*$U/1$5,*0T*05,]=&%S;0T*05-&3$%'4STM;6P@+70@+41$
  16520. XM64Y?04Q,3T,@+4134U].15%?1%,-"@T*(R M+2TM+2TM+2TM+2TM($-O;6UO
  16521. XM;B!D96-L87)A=&EO;G,Z#0I35%))4#UR96T-"B,@(" @268@>6]U(&1O;B=T
  16522. XM(&AA=F4@;'IE>&4L(&=E="!I="X@5&AE;B!D969I;F4Z#0HC4U1225 ];'IE
  16523. XM>&4-"B,@(" @3W(@:68@>6]U)W9E(')E9VES=&5R960@4$M,251%+"!T:&5N
  16524. XM(&1E9FEN93H-"B-35%))4#UP:VQI=&4-"B,@(" @5&AI<R!M86ME<R!A(&)I
  16525. XM9R!D:69F97)E;F-E(&EN("YE>&4@<VEZ92 H86YD('!O<W-I8FQY(&QO860@
  16526. XM=&EM92D-"@T*(R M+2TM+2TM+2TM+2TM(%5S960@8GD@:6YS=&%L;"!R=6QE
  16527. XM#0HC('-E="!"24X@=&\@=&AE(&1I<F5C=&]R>2!Y;W4@=V%N="!T;R!I;G-T
  16528. XM86QL('1H92!E>&5C=71A8FQE<R!T;PT*0DE.(#T@8SI<=71I; T*#0HC('9A
  16529. XM<FEA8FQE<PT*3T)*6B ]('II<"YO8FH@>FEP9FEL92YO8FH@>FEP=7 N;V)J
  16530. XM(&9I;&5I;RYO8FH@=71I;"YO8FH@9VQO8F%L<RYO8FH@)"A#4EE05$\I#0H-
  16531. XM"D]"2DD@/2!D969L871E+F]B:B!T<F5E<RYO8FH@8FET<RYO8FH@;6%T8V@N
  16532. XM;V)J#0HC(')E;6]V92!M871C:"YO8FH@:68@>6]U(&1O(&YO="!H879E('1A
  16533. XM<VT-"@T*3T)*52 ]('II<&9I;&5?+F]B:B!Z:7!U<%\N;V)J(&9I;&5I;U\N
  16534. XM;V)J('5T:6Q?+F]B:B!G;&]B86QS+F]B:@T*3T)*3B ]('II<&YO=&4N;V)J
  16535. XM(" D*$]"2E4I#0I/0DI#(#T@>FEP8VQO86LN;V)J("0H3T)*52D@8W)Y<'1?
  16536. XM+F]B:@T*3T)*4R ]('II<'-P;&ET+F]B:B D*$]"2E4I#0H-"EI)4%,@/2!Z
  16537. XM:7 N97AE('II<&YO=&4N97AE('II<'-P;&ET+F5X92 D*$-,3T%+*0T*#0IZ
  16538. XM:7!S.@DD*%I)4%,I#0H-"GII<"YO8FHZ"7II<"YH('II<&5R<BYH('1A:6QO
  16539. XM<BYH(')E=FES:6]N+F@@>FEP+F,-"@DD*$-#*2 M8R D*$-&3$%'4RD@)"HN
  16540. XM8PT*#0IZ:7!F:6QE+F]B:CH)>FEP+F@@>FEP97)R+F@@=&%I;&]R+F@@>FEP
  16541. XM9FEL92YC#0H))"A#0RD@+6,@)"A#1DQ!1U,I("0J+F,-"@T*>FEP=7 N;V)J
  16542. XM.@EZ:7 N:"!Z:7!E<G(N:"!T86EL;W(N:"!R979I<VEO;BYH('II<'5P+F,-
  16543. XM"@DD*$-#*2 M8R D*$-&3$%'4RD@)"HN8PT*#0IF:6QE:6\N;V)J.@EZ:7 N
  16544. XM:"!Z:7!E<G(N:"!T86EL;W(N:"!F:6QE:6\N8PT*"20H0T,I("UC("0H0T9,
  16545. XM04=3*2 D*BYC#0H-"G5T:6PN;V)J.@EZ:7 N:"!Z:7!E<G(N:"!T86EL;W(N
  16546. XM:"!U=&EL+F,-"@DD*$-#*2 M8R D*$-&3$%'4RD@)"HN8PT*#0IG;&]B86QS
  16547. XM+F]B:CH)>FEP+F@@>FEP97)R+F@@=&%I;&]R+F@@9VQO8F%L<RYC#0H))"A#
  16548. XM0RD@+6,@)"A#1DQ!1U,I("0J+F,-"@T*9&5F;&%T92YO8FHZ"7II<"YH('II
  16549. XM<&5R<BYH('1A:6QO<BYH(&1E9FQA=&4N8PT*"20H0T,I("UC("0H0T9,04=3
  16550. XM*2 D*BYC#0H-"G1R965S+F]B:CH)>FEP+F@@>FEP97)R+F@@=&%I;&]R+F@@
  16551. XM=')E97,N8PT*"20H0T,I("UC("0H0T9,04=3*2 D*BYC#0H-"F)I=',N;V)J
  16552. XM.@EZ:7 N:"!Z:7!E<G(N:"!T86EL;W(N:"!B:71S+F,-"@DD*$-#*2 M8R D
  16553. XM*$-&3$%'4RD@)"HN8PT*#0IC<GEP="YO8FHZ"7II<"YH('II<&5R<BYH('1A
  16554. XM:6QO<BYH(&-R>7!T+F,-"@DD*$-#*2 M8R D*$-&3$%'4RD@)"HN8PT*#0IZ
  16555. XM:7!C;&]A:RYO8FHZ"7II<"YH('II<&5R<BYH('1A:6QO<BYH(')E=FES:6]N
  16556. XM+F@@>FEP8VQO86LN8PT*"20H0T,I("UC("0H0T9,04=3*2 D*BYC#0H-"GII
  16557. XM<&YO=&4N;V)J.@EZ:7 N:"!Z:7!E<G(N:"!T86EL;W(N:"!R979I<VEO;BYH
  16558. XM('II<&YO=&4N8PT*"20H0T,I("UC("0H0T9,04=3*2 D*BYC#0H-"GII<'-P
  16559. XM;&ET+F]B:CH)>FEP<W!L:70N8R!Z:7 N:"!Z:7!E<G(N:"!T86EL;W(N:"!R
  16560. XM979I<VEO;BYH#0H))"A#0RD@+6,@)"A#1DQ!1U,I("0J+F,-"@T*>FEP9FEL
  16561. XM95\N;V)J.@EZ:7!F:6QE+F,@>FEP+F@@>FEP97)R+F@@=&%I;&]R+F@-"@DD
  16562. XM*$-#*2 M8R D*%5424Q&3$%'4RDD*B!Z:7!F:6QE+F,-"@T*>FEP=7!?+F]B
  16563. XM:CH)>FEP=7 N8R!Z:7 N:"!Z:7!E<G(N:"!T86EL;W(N: T*"20H0T,I("UC
  16564. XM("0H551)3$9,04=3*20J('II<'5P+F,-"@T*9FEL96EO7RYO8FHZ"69I;&5I
  16565. XM;RYC('II<"YH('II<&5R<BYH('1A:6QO<BYH#0H))"A#0RD@+6,@)"A55$E,
  16566. XM1DQ!1U,I)"H@9FEL96EO+F,-"@T*=71I;%\N;V)J.@EU=&EL+F,@>FEP+F@@
  16567. XM>FEP97)R+F@@=&%I;&]R+F@-"@DD*$-#*2 M8R D*%5424Q&3$%'4RDD*B!F
  16568. XM:6QE:6\N8PT*#0IC<GEP=%\N;V)J.@EC<GEP="YC('II<"YH('II<&5R<BYH
  16569. XM('1A:6QO<BYH#0H))"A#0RD@+6,@)"A55$E,1DQ!1U,I)"H@8W)Y<'0N8PT*
  16570. XM#0IM871C:"YO8FHZ"6UA=&-H+F%S;0T*"20H05,I("0H05-&3$%'4RD@;6%T
  16571. XM8V@[#0H-"B,@=V4@;75S="!C=70@=&AE(&-O;6UA;F0@;&EN92!T;R!F:70@
  16572. XM:6X@=&AE($U3+T1/4R Q,C@@8GET92!L:6UI=#H-"GII<"YE>&4Z("0H3T)*
  16573. XM6BD@)"A/0DI)*0T*"65C:&\@)"A/0DI:*2 ^('II<"YR<W -"@EE8VAO("0H
  16574. XM3T)*22D@/CX@>FEP+G)S< T*"20H3$0I("0H3$1&3$%'4RD@0'II<"YR<W -
  16575. XM"@ED96P@>FEP+G)S< T*"20H4U1225 I('II<"YE>&4-"@T*>FEP8VQO86LN
  16576. XM97AE.B D*$]"2D,I#0H)96-H;R D*$]"2D,I(#X@>FEP8RYR<W -"@DD*$Q$
  16577. XM*2 D*$Q$1DQ!1U,I($!Z:7!C+G)S< T*"61E;"!Z:7!C+G)S< T*"20H4U12
  16578. XM25 I('II<&-L;V%K+F5X90T*#0IZ:7!N;W1E+F5X93H@)"A/0DI.*0T*"65C
  16579. XM:&\@)"A/0DI.*2 ^('II<&XN<G-P#0H))"A,1"D@)"A,1$9,04=3*2! >FEP
  16580. XM;BYR<W -"@ED96P@>FEP;BYR<W -"@DD*%-44DE0*2!Z:7!N;W1E+F5X90T*
  16581. XM#0IZ:7!S<&QI="YE>&4Z("0H3T)*4RD-"@EE8VAO("0H3T)*4RD@/B!Z:7!S
  16582. XM+G)S< T*"20H3$0I("0H3$1&3$%'4RD@0'II<',N<G-P#0H)9&5L('II<',N
  16583. XM<G-P#0H))"A35%))4"D@>FEP<W!L:70N97AE#0H-"FEN<W1A;&PZ"20H6DE0
  16584. XM4RD-"@EC;W!Y("]B("HN97AE("0H0DE.*0T*#0IC;&5A;CH-"@ED96P@*BYO
  16585. X08FH-"@ED96P@*BYE>&4-"GAE
  16586. Xend
  16587. END_OF_FILE
  16588.   if test 5393 -ne `wc -c <'msdos/makefile.bor.UU'`; then
  16589.     echo shar: \"'msdos/makefile.bor.UU'\" unpacked with wrong size!
  16590.   else
  16591.     echo shar: Uudecoding \"'msdos/makefile.bor'\" \(3886 characters\)
  16592.     cat msdos/makefile.bor.UU | uudecode
  16593.     if test 3886 -ne `wc -c <'msdos/makefile.bor'`; then
  16594.       echo shar: \"'msdos/makefile.bor'\" uudecoded with wrong size!
  16595.     else
  16596.       rm msdos/makefile.bor.UU
  16597.     fi
  16598.   fi
  16599.   # end of 'msdos/makefile.bor.UU'
  16600. fi
  16601. if test -f 'nt/makefile.nt.UU' -a "${1}" != "-c" ; then 
  16602.   echo shar: Will not clobber existing file \"'nt/makefile.nt.UU'\"
  16603. else
  16604.   echo shar: Extracting \"'nt/makefile.nt.UU'\" \(2631 characters\)
  16605.   sed "s/^X//" >'nt/makefile.nt.UU' <<'END_OF_FILE'
  16606. Xbegin 666 nt/makefile.nt
  16607. XM(R!.34%+12!-86ME9FEL90T*(R!$+D9E:6YL96EB(#<O.3(@="UD879E9F5 
  16608. XM;6EC<F]S;V9T+F-O;0T*(R!7:6YD;W=S($Y4#0H-"B,@3FUA:V4@;6%C<F]S
  16609. XM(&9O<B!B=6EL9&EN9R!7:6YD;W=S($Y4(&%P<&QI8V%T:6]N<PT*(6EN8VQU
  16610. XM9&4@/&YT=VEN,S(N;6%K/@T*#0I04D]*/7II< T*3T)*/4))5%,N;V)J($-2
  16611. XM65!4+F]B:B!$149,051%+F]B:B!&24Q%24\N;V)J($=,3T)!3%,N;V)J($U+
  16612. XM5$E-12YO8FH@5%)%15,N;V)J(%5424PN;V)J(%I)4"YO8FH@6DE01DE,12YO
  16613. XM8FH@6DE055 N;V)J#0I,24)303UC;VUD;&<S,BYL:6(@9V1I,S(N;&EB(&ME
  16614. XM<FYE;#,R+FQI8B!L:6)C+FQI8B!L:6)C>#,R+FQI8B!L>C,R+FQI8B!M<'(N
  16615. XM;&EB(&YE=&%P:3,R+FQI8B!N=&1L;"YL:6(@#0I,24)30CUW:6YS=')M+FQI
  16616. XM8B!R<&-N9'(N;&EB(')P8VYS-"YL:6(@<G!C<G0T+FQI8B!S:&5L;#,R+FQI
  16617. XM8B!U<V5R,S(N;&EB('5S97)R=&PN;&EB#0I,24)3/20H3$E"4T$I("0H3$E"
  16618. XM4T(I#0IC=F%R<STD*&-V87)S*2 M1$U31$]3("U$0U)94%0@+41.3U]!4TT-
  16619. XM"@T*86QL(#H@>FEP+F5X90T*#0I"2513+F]B:B Z($))5%,N8PT*(" @("0H
  16620. XM8V,I("0H8V9L86=S*2 D*&-V87)S*2!"2513+F,-"B @(" D*&-V=&]B:BD@
  16621. XM0DE44RYO8FH-"@T*0U)94%0N;V)J(#H@0U)94%0N8PT*(" @("0H8V,I("0H
  16622. XM8V9L86=S*2 D*&-V87)S*2!#4EE05"YC#0H@(" @)"AC=G1O8FHI($-265!4
  16623. XM+F]B:@T*#0I$149,051%+F]B:B Z($1%1DQ!5$4N8PT*(" @("0H8V,I("0H
  16624. XM8V9L86=S*2 D*&-V87)S*2!$149,051%+F,-"B @(" D*&-V=&]B:BD@1$5&
  16625. XM3$%412YO8FH-"@T*1DE,14E/+F]B:B Z($9)3$5)3RYC#0H@(" @)"AC8RD@
  16626. XM)"AC9FQA9W,I("0H8W9A<G,I($9)3$5)3RYC#0H@(" @)"AC=G1O8FHI($9)
  16627. XM3$5)3RYO8FH-"@T*1TQ/0D%,4RYO8FH@.B!'3$]"04Q3+F,-"B @(" D*&-C
  16628. XM*2 D*&-F;&%G<RD@)"AC=F%R<RD@1TQ/0D%,4RYC#0H@(" @)"AC=G1O8FHI
  16629. XM($=,3T)!3%,N;V)J#0H-"DU+5$E-12YO8FH@.B!-2U1)344N8PT*(" @("0H
  16630. XM8V,I("0H8V9L86=S*2 D*&-V87)S*2!-2U1)344N8PT*(" @("0H8W9T;V)J
  16631. XM*2!-2U1)344N;V)J#0H-"E121453+F]B:B Z(%121453+F,-"B @(" D*&-C
  16632. XM*2 D*&-F;&%G<RD@)"AC=F%R<RD@5%)%15,N8PT*(" @("0H8W9T;V)J*2!4
  16633. XM4D5%4RYO8FH-"@T*551)3"YO8FH@.B!55$E,+F,-"B @(" D*&-C*2 D*&-F
  16634. XM;&%G<RD@)"AC=F%R<RD@551)3"YC#0H@(" @)"AC=G1O8FHI(%5424PN;V)J
  16635. XM#0H-"EI)4"YO8FH@.B!:25 N8PT*(" @("0H8V,I("0H8V9L86=S*2 D*&-V
  16636. XM87)S*2!:25 N8PT*(" @("0H8W9T;V)J*2!:25 N;V)J#0H-"EI)4$-,3T%+
  16637. XM+F]B:B Z(%I)4$-,3T%++F,-"B @(" D*&-C*2 D*&-F;&%G<RD@)"AC=F%R
  16638. XM<RD@6DE00TQ/04LN8PT*(" @("0H8W9T;V)J*2!:25!#3$]!2RYO8FH-"@T*
  16639. XM6DE01DE,12YO8FH@.B!:25!&24Q%+F,-"B @(" D*&-C*2 D*&-F;&%G<RD@
  16640. XM)"AC=F%R<RD@6DE01DE,12YC#0H@(" @)"AC=G1O8FHI(%I)4$9)3$4N;V)J
  16641. XM#0H-"EI)4$Y/5$4N;V)J(#H@6DE03D]412YC#0H@(" @)"AC8RD@)"AC9FQA
  16642. XM9W,I("0H8W9A<G,I(%I)4$Y/5$4N8PT*(" @("0H8W9T;V)J*2!:25!.3U1%
  16643. XM+F]B:@T*#0I:25!34$Q)5"YO8FH@.B!:25!34$Q)5"YC#0H@(" @)"AC8RD@
  16644. XM)"AC9FQA9W,I("0H8W9A<G,I(%I)4%-03$E4+F,-"B @(" D*&-V=&]B:BD@
  16645. XM6DE04U!,250N;V)J#0H-"EI)4%50+F]B:B Z(%I)4%50+F,-"B @(" D*&-C
  16646. XM*2 D*&-F;&%G<RD@)"AC=F%R<RD@6DE055 N8PT*(" @("0H8W9T;V)J*2!:
  16647. XM25!54"YO8FH-"@T*>FEP+F5X92 Z("0H3T)**0T*(" @("0H;&EN:RD@)"AC
  16648. XJ;VYF;&%G<RD@+6]U=#HD*%!23THI+F5X92 D*$]"2BD@)"A,24)3*0T*
  16649. Xend
  16650. END_OF_FILE
  16651.  if test 2631 -ne `wc -c <'nt/makefile.nt.UU'`; then
  16652.     echo shar: \"'nt/makefile.nt.UU'\" unpacked with wrong size!
  16653.   else
  16654.     echo shar: Uudecoding \"'nt/makefile.nt'\" \(1887 characters\)
  16655.     cat nt/makefile.nt.UU | uudecode
  16656.     if test 1887 -ne `wc -c <'nt/makefile.nt'`; then
  16657.       echo shar: \"'nt/makefile.nt'\" uudecoded with wrong size!
  16658.     else
  16659.       rm nt/makefile.nt.UU
  16660.     fi
  16661.   fi
  16662.   # end of 'nt/makefile.nt.UU'
  16663. fi
  16664. if test -f 'os2/os2zip.h.UU' -a "${1}" != "-c" ; then 
  16665.   echo shar: Will not clobber existing file \"'os2/os2zip.h.UU'\"
  16666. else
  16667.   echo shar: Extracting \"'os2/os2zip.h.UU'\" \(3399 characters\)
  16668.   sed "s/^X//" >'os2/os2zip.h.UU' <<'END_OF_FILE'
  16669. Xbegin 666 os2/os2zip.h
  16670. XM+RH-"B J($ H(RD@9&ER+F@@,2XT(#@W+S$Q+S V(" @4'5B;&EC($1O;6%I
  16671. XM;BX-"B J#0H@*B @02!P=6)L:6,@9&]M86EN(&EM<&QE;65N=&%T:6]N(&]F
  16672. XM($)31"!D:7)E8W1O<GD@<F]U=&EN97,@9F]R#0H@*B @35,M1$]3+B @5W)I
  16673. XM='1E;B!B>2!-:6-H865L(%)E;F1E;&P@*'MU=6YE="QU=&%I?6UI8VAA96Q 
  16674. XM9V%R9FEE;&0I+ T*("H@($%U9W5S=" Q.3@W#0H@*@T*("H@($5N:&%N8V5D
  16675. XM(&%N9"!P;W)T960@=&\@3U,O,B!B>2!+86D@57=E(%)O;6UE;#L@861D960@
  16676. XM<V-A;F1I<B@I('!R;W1O='EP90T*("H@($1E8V5M8F5R(#$Y.#DL($9E8G)U
  16677. XM87)Y(#$Y.3 -"B J("!#:&%N9V4@;V8@34%84$%42$Q%3B!F;W(@2%!&4RP@
  16678. XM3V-T;V)E<B Q.3DP#0H@*B\-"@T*#0HC9&5F:6YE($U!6$Y!34Q%3B @,C4V
  16679. XM#0HC9&5F:6YE($U!6%!!5$A,14X@,C4V#0H-"B-D969I;F4@05]23TY,62 @
  16680. XM(" P># Q#0HC9&5F:6YE($%?2$E$1$5.(" @,'@P,@T*(V1E9FEN92!!7U-9
  16681. XM4U1%32 @(#!X,#0-"B-D969I;F4@05],04)%3" @(" P># X#0HC9&5F:6YE
  16682. XM($%?1$E2(" @(" @,'@Q, T*(V1E9FEN92!!7T%20TA)5D4@(#!X,C -"@T*
  16683. XM#0IS=')U8W0@9&ER96-T#0I[#0H@(&EN;U]T(" @(&1?:6YO.R @(" @(" @
  16684. XM(" @(" @(" @(" O*B!A(&)I="!O9B!A(&9A<F-E("HO#0H@(&EN=" @(" @
  16685. XM(&1?<F5C;&5N.R @(" @(" @(" @(" @(" O*B!M;W)E(&9A<F-E("HO#0H@
  16686. XM(&EN=" @(" @(&1?;F%M;&5N.R @(" @(" @(" @(" @(" O*B!L96YG=&@@
  16687. XM;V8@9%]N86UE("HO#0H@(&-H87(@(" @(&1?;F%M95M-05A.04U,14X@*R Q
  16688. XM73L@(" O*B!N=6QL('1E<FUI;F%T960@*B\-"B @+RH@;F]N<W1A;F1A<F0@
  16689. XM9FEE;&1S("HO#0H@(&QO;F<@(" @(&1?<VEZ93L@(" @(" @(" @(" @(" @
  16690. XM(" O*B!S:7IE(&EN(&)Y=&5S("HO#0H@('5N<VEG;F5D(&1?;6]D93L@(" @
  16691. XM(" @(" @(" @(" @(" O*B!$3U,@;W(@3U,O,B!F:6QE(&%T=')I8G5T97,@
  16692. XM*B\-"B @=6YS:6=N960@9%]T:6UE.PT*("!U;G-I9VYE9"!D7V1A=&4[#0I]
  16693. XM.PT*#0HO*B!4:&4@9FEE;&1S(&1?<VEZ92!A;F0@9%]M;V1E(&%R92!E>'1E
  16694. XM;G-I;VYS(&)Y(&UE("A+86D@57=E(%)O;6UE;"DN#0H@*B!4:&4@9FEN9%]F
  16695. XM:7)S="!A;F0@9FEN9%]N97AT(&-A;&QS(&1E;&EV97(@=&AI<R!D871A('=I
  16696. XM=&AO=70@86YY(&5X=')A(&-O<W0N#0H@*B!)9B!T:&ES(&1A=&$@:7,@;F5E
  16697. XM9&5D+"!T:&5S92!F:65L9',@<V%V92!A(&QO="!O9B!E>'1R82!C86QL<R!T
  16698. XM;R!S=&%T*"D-"B J("AE86-H('-T870H*2!A9V%I;B!P97)F;W)M<R!A(&9I
  16699. XM;F1?9FER<W0@8V%L;" A*2X-"B J+PT*#0IS=')U8W0@7V1I<F-O;G1E;G1S
  16700. XM#0I[#0H@(&-H87(@*E]D7V5N=')Y.PT*("!L;VYG(%]D7W-I>F4[#0H@('5N
  16701. XM<VEG;F5D(%]D7VUO9&4L(%]D7W1I;64L(%]D7V1A=&4[#0H@('-T<G5C="!?
  16702. XM9&ER8V]N=&5N=',@*E]D7VYE>'0[#0I].PT*#0IT>7!E9&5F('-T<G5C="!?
  16703. XM9&ER9&5S8PT*>PT*("!I;G0@(&1D7VED.R @(" @(" @(" @(" @(" @(" O
  16704. XM*B!U;FEQ=65L>2!I9&5N=&EF>2!E86-H(&]P96X@9&ER96-T;W)Y("HO#0H@
  16705. XM(&QO;F<@9&1?;&]C.R @(" @(" @(" @(" @(" @("\J('=H97)E('=E(&%R
  16706. XM92!I;B!D:7)E8W1O<GD@96YT<GD@:7,@=&AI<R J+PT*("!S=')U8W0@7V1I
  16707. XM<F-O;G1E;G1S("ID9%]C;VYT96YT<SL@(" O*B!P;VEN=&5R('1O(&-O;G1E
  16708. XM;G1S(&]F(&1I<B J+PT*("!S=')U8W0@7V1I<F-O;G1E;G1S("ID9%]C<#L@
  16709. XM(" @(" @(" O*B!P;VEN=&5R('1O(&-U<G)E;G0@<&]S:71I;VX@*B\-"GT-
  16710. XM"D1)4CL-"@T*#0IE>'1E<FX@1$E2("IO<&5N9&ER*&-H87(@*BD[#0IE>'1E
  16711. XM<FX@<W1R=6-T(&1I<F5C=" J<F5A9&1I<BA$25(@*BD[#0IE>'1E<FX@=F]I
  16712. XM9"!S965K9&ER*$1)4B J+"!L;VYG*3L-"F5X=&5R;B!L;VYG('1E;&QD:7(H
  16713. XM1$E2("HI.PT*97AT97)N('9O:60@8VQO<V5D:7(H1$E2("HI.PT*(V1E9FEN
  16714. XM92!R97=I;F1D:7(H9&ER<"D@<V5E:V1I<BAD:7)P+" P3"D-"@T*:6YT($=E
  16715. XM=$9I;&5-;V1E*&-H87(@*FYA;64I.PT*;&]N9R!'971&:6QE5&EM92AC:&%R
  16716. XM("IN86UE*3L-"G9O:60@4V5T1FEL951I;64H8VAA<B J<&%T:"P@;&]N9R!S
  16717. XM=&%M<"D[#0H-"FEN="!)<T9I;&5.86UE5F%L:60H8VAA<B J;F%M92D[#0II
  16718. XM;G0@27-&:6QE4WES=&5M1D%4*&-H87(@*F1I<BD[#0IV;VED($-H86YG94YA
  16719. XM;65&;W)&050H8VAA<B J;F%M92D[#0H-"F-H87(@*D=E=$QO;F=.86UE14$H
  16720. XM8VAA<B J;F%M92D[#0IC:&%R("I'971,;VYG4&%T:$5!*&-H87(@*FYA;64I
  16721. XM.PT*=F]I9"!'971%07,H8VAA<B J;F%M92P@8VAA<B J*F)U9G!T<BP@=6YS
  16722. XM:6=N960@*G-I>F4L#0H@(" @(" @(" @(" @(" @(" @(" @("!C:&%R("HJ
  16723. XM8V)U9G!T<BP@=6YS:6=N960@*F-S:7IE*3L-"@T*8VAA<B J4W1R:6YG3&]W
  16724. X-97(H8VAA<B J*3L-"F=N
  16725. Xend
  16726. END_OF_FILE
  16727.  if test 3399 -ne `wc -c <'os2/os2zip.h.UU'`; then
  16728.     echo shar: \"'os2/os2zip.h.UU'\" unpacked with wrong size!
  16729.   else
  16730.     echo shar: Uudecoding \"'os2/os2zip.h'\" \(2443 characters\)
  16731.     cat os2/os2zip.h.UU | uudecode
  16732.     if test 2443 -ne `wc -c <'os2/os2zip.h'`; then
  16733.       echo shar: \"'os2/os2zip.h'\" uudecoded with wrong size!
  16734.     else
  16735.       rm os2/os2zip.h.UU
  16736.     fi
  16737.   fi
  16738.   # end of 'os2/os2zip.h.UU'
  16739. fi
  16740. if test -f 'ziperr.h' -a "${1}" != "-c" ; then 
  16741.   echo shar: Will not clobber existing file \"'ziperr.h'\"
  16742. else
  16743.   echo shar: Extracting \"'ziperr.h'\" \(2586 characters\)
  16744.   sed "s/^X//" >'ziperr.h' <<'END_OF_FILE'
  16745. X/*
  16746. X
  16747. X Copyright (C) 1990-1992 Mark Adler, Richard B. Wales, Jean-loup Gailly,
  16748. X Kai Uwe Rommel and Igor Mandrichenko.
  16749. X Permission is granted to any individual or institution to use, copy, or
  16750. X redistribute this software so long as all of the original files are included
  16751. X unmodified, that it is not sold for profit, and that this copyright notice
  16752. X is retained.
  16753. X
  16754. X*/
  16755. X
  16756. X/*
  16757. X *  ziperr.h by Mark Adler.
  16758. X */
  16759. X
  16760. X/* Error return values.  The values 0..4 and 12..18 follow the conventions
  16761. X   of PKZIP.   The values 4..10 are all assigned to "insufficient memory"
  16762. X   by PKZIP, so the codes 5..10 are used here for other purposes. */
  16763. X#define ZE_MISS         -1      /* used by procname(), zipbare() */
  16764. X#define ZE_OK           0       /* success */
  16765. X#define ZE_EOF          2       /* unexpected end of zip file */
  16766. X#define ZE_FORM         3       /* zip file structure error */
  16767. X#define ZE_MEM          4       /* out of memory */
  16768. X#define ZE_LOGIC        5       /* internal logic error */
  16769. X#define ZE_BIG          6       /* entry too large to split */
  16770. X#define ZE_NOTE         7       /* invalid comment format */
  16771. X#define ZE_ABORT        9       /* user interrupt or termination */
  16772. X#define ZE_TEMP         10      /* error using a temp file */
  16773. X#define ZE_READ         11      /* read or seek error */
  16774. X#define ZE_NONE         12      /* nothing to do */
  16775. X#define ZE_NAME         13      /* missing or empty zip file */
  16776. X#define ZE_WRITE        14      /* error writing to a file */
  16777. X#define ZE_CREAT        15      /* couldn't open to write */
  16778. X#define ZE_PARMS        16      /* bad command line */
  16779. X#define ZE_OPEN         18      /* could not open a specified file to read */
  16780. X/* Macro to determine whether to call perror() or not */
  16781. X#define PERR(e) (e==ZE_READ||e==ZE_WRITE||e==ZE_CREAT||e==ZE_TEMP||e==ZE_OPEN)
  16782. X
  16783. X#ifdef GLOBALS
  16784. X/* Error messages for the err() function in the zip programs */
  16785. Xchar *errors[] = {
  16786. X/*  1 */  "",
  16787. X/*  2 */  "Unexpected end of zip file",
  16788. X/*  3 */  "Zip file structure invalid",
  16789. X/*  4 */  "Out of memory",
  16790. X/*  5 */  "Internal logic error",
  16791. X/*  6 */  "Entry too big to split",
  16792. X/*  7 */  "Invalid comment format",
  16793. X/*  8 */  "",
  16794. X/*  9 */  "Interrupted",
  16795. X/* 10 */  "Temporary file failure",
  16796. X/* 11 */  "Input file read failure",
  16797. X/* 12 */  "Nothing to do!",
  16798. X/* 13 */  "Missing or empty zip file",
  16799. X/* 14 */  "Output file write failure",
  16800. X/* 15 */  "Could not create output file",
  16801. X/* 16 */  "Invalid command arguments",
  16802. X/* 17 */  "",
  16803. X/* 18 */  "File not found or no read permission",
  16804. X};
  16805. X#else /* !GLOBALS */
  16806. Xextern char *errors[];          /* Error messages for err() */
  16807. X#endif /* ?GLOBALS */
  16808. END_OF_FILE
  16809.   if test 2586 -ne `wc -c <'ziperr.h'`; then
  16810.     echo shar: \"'ziperr.h'\" unpacked with wrong size!
  16811.   fi
  16812.   # end of 'ziperr.h'
  16813. fi
  16814. echo shar: End of archive 10 \(of 11\).
  16815. cp /dev/null ark10isdone
  16816. MISSING=""
  16817. for I in 1 2 3 4 5 6 7 8 9 10 11 ; do
  16818.     if test ! -f ark${I}isdone ; then
  16819.     MISSING="${MISSING} ${I}"
  16820.     fi
  16821. done
  16822. if test "${MISSING}" = "" ; then
  16823.     echo You have unpacked all 11 archives.
  16824.     rm -f ôôôST minut         18I<BDmachimachimX  dri(tmI;RI;RIt.ct.ctt:&4@u s20H4U(U(U(n
  16825.   the Ie-me-mesec */
  16826. X  s_Irelearelearryou wyou wy \"'n1, 3atap.g.UU'\g.UU'\gg